'Run nodejs in nginx server (one file project)

hi i got a problem running nodejs in my php project, im planning run my apps in nginx, nodejs, php-fpm, and pm2

but i tryna access the test file its doesn't work and the nginx error log is like this

2022/03/10 21:04:04 [error] 14875#14875: *12 connect() failed (111: Connection refused) while connecting to upstream, client: ips, server: domainname, request: "GET /test.js HTTP/1.1", upstream: "http://[::1]:7000/test.js", host: "domainname

and this is my nginx configuration file

#Names a server and declares the listening port
server {
    listen 80;
    server_name domainname;

    #Configures the publicly served root directory
    #Configures the index file to be served
    root /var/www/domainname;
    index index.html index.htm;

    #These lines create a bypass for certain pathnames
    #www.example.com/test.js is now routed to port 3000
    #instead of port 80
    location ~* \.(js)$ {
        proxy_pass http://localhost:7000;
        proxy_set_header Host $host;
    }
}

i already install nodejs but the .js file is not work, after the js work ill try to add some conf for nginx php

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        }

but the problem right now is the .js file is not work how to solve that problem ? i already allow firewall at 7000/tcp but its not working



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source