Serving multiple node apps with nginx on same domain

后端 未结 3 482
余生分开走
余生分开走 2021-01-01 00:54

I would like to host 2 different node applications with nginx from the same domain and am having some trouble. I would like to have:

mydomain.com point to n

相关标签:
3条回答
  • 2021-01-01 01:23

    Just found out what the problem was. Though my nginx configs were correct, I had not added my desired subdomain to my domain name provider (namecheap). I added my subdomain on namecheap, and everything is working correctly now.

    0 讨论(0)
  • 2021-01-01 01:29

    you should config your nginx file like this

    server {
            listen 80;  
            server_name biger.yourdomain.cn;
    
    
            access_log      /data/log/nginx/access_ab.log;
            error_log       /data/log/nginx/error_ab.log;
    
            location /firstApp {
                 proxy_store off;
                 proxy_redirect off;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_set_header X-Real-IP $remote_addr;
                 proxy_set_header Host $http_host;
                 proxy_pass http://localhost:8001/;
            }
    
    }
    

    maeby you need add this code to your project

    app.enable('trust proxy');
    
    0 讨论(0)
  • 2021-01-01 01:30

    I was facing the same problem, after spending time on research I wrote a blogpost where I explained with details how I solved it, I hope it helps. Here it is: http://blog.donaldderek.com/2013/08/cf-i-configure-your-staging-machine-with-node-js-and-nginx/

    0 讨论(0)
提交回复
热议问题