ISP Config - Nginx - Nginx Directives for Node Website

Discussion in 'Installation/Configuration' started by P4R4, Feb 24, 2022.

  1. P4R4

    P4R4 New Member

    So I have this node website which need to be redirected to port 3000 of localhost. I've looked through many threads and everything I do, results in failure. The only thing that is working, is when I change the documentRoot of the website. I've confirmed this by making a html page and it works.

    This is what is recommended for the site to work but I don't know how to apply it to ISPconfig.
    Code:
    server {
       
      server_name example.com; # Change domain to your domain
       
      location / {
        proxy_pass http://localhost:3000; # Change ONLY the port if needed.
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
      }
    }
    
    What I have right now in the nginx directives is
    Code:
    root /home/faxcad/
    I also have enable proxy checked as you can see in the image below.

    upload_2022-2-23_16-37-8.png

    Thanks for the help in advance!
     
  2. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Disable the PROXY protocol as you are not using it, and you then put the needed directives in the nginx Directives field; try just the location directive, as your custom directives should be put inside a server {} block, and the server name set already. If that doesn't work right away, search the forums for similar posts, as others have posted working directives in the past.
     
  3. P4R4

    P4R4 New Member

    I've tried that already I still get an error 500, As soon as I put in a index.html file then the error 500 disappears.

    These are my current Directives

    Code:
    server {
    
    root /home/faxcad/
    
    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
      }
    }
    I also thought that I didn't have to put the server block in as the directives get added between those blocks anyways not sure if its good to have more than 1 server block
     
    Last edited: Feb 24, 2022
  4. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    No, you shouldn't. I am also not convinced that that directives are working but you should already knew that when you run them.

    Search "site:howtoforge.com nginx directives delete" and see various examples on overriding via directives if you do not have the ISPConfig Manual.
     
  5. P4R4

    P4R4 New Member

    I mean yeah I've noticed it's not working lol, I've been searching all day.
     
  6. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    All I can see is that you want proxy config and root path to be changed accordingly to your needs so you were right on checking proxy. However you need to change the default ISPConfig proxy config and as well root path, so overriding them becomes necessary and that is what you must search.

    So first, see the vhost created by ISPConfig when you ticked proxy then do the necessary overrides based on your research.
     
  7. P4R4

    P4R4 New Member

    I'll never get this working
     
  8. P4R4

    P4R4 New Member

    You have no idea how much time,I've spent on this issue :(
     
  9. P4R4

    P4R4 New Member

    Nevermind, got it to work, just don't know why it started working when I tried this earlier

    Code:
    ##delete## root {DOCROOT};
    
    ##merge## root /home/faxcad/;
    
      location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
      }
     
    Jesse Norell likes this.
  10. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    I think it is better for you to learn this way whether you like it or not. :rolleyes:
     

Share This Page