Hosting two Node.JS apps on same domain -
i have 2 node js applications running on same box , run first node js app routing except if url www.domain.com/blog go other node js application. possible setup or have setup subdomains , use nginx or something?
you can achieve using nginx reverse proxy.
assuming have blog node process running on port 3000 , node process on 3001 simple config like;
upstream blog { server 127.0.0.1:3000; } upstream other { server 127.0.0.1:3001; } server { listen 80; server_name www.domain.com; location /blog { proxy_pass http://blog; proxy_http_version 1.1; proxy_set_header host $http_host; proxy_set_header upgrade $http_upgrade; proxy_set_header connection "upgrade"; proxy_set_header x-real-ip $proxy_protocol_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header x-forwarded-proto tcp; proxy_set_header x-nginx-proxy true; } location / { proxy_pass http://other; proxy_http_version 1.1; proxy_set_header host $http_host; proxy_set_header upgrade $http_upgrade; proxy_set_header connection "upgrade"; proxy_set_header x-real-ip $proxy_protocol_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header x-forwarded-proto tcp; proxy_set_header x-nginx-proxy true; } }
Comments
Post a Comment