Reputation: 787
I am using nginx on centos 7.
I am reverse proxying a remote nodejs server on the same LAN to the nginx root / as per the below:
location / {
proxy_pass http://192.168.1.104:3000/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
This works fine for serving my website - all external requests on port 80 are rewritten to use https which has been configured in nginx e.g nginx forwards any incoming http requests to https and deals with rewrites and forwarding so that the nodejs content is served over ssl even though ssl hasn't been configured within the node application.
e.g my site can be accessed at https://example.com
I now want to reverse proxy another nodejs app so that it appears at a location which is prefixed with https://example.com e.g: https://example.com/node2/
I've tried using the below config for the second node server...
location /node2/ {
proxy_pass http://192.168.1.100:3000/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
When I load the https://example.com/node2/ url, the html of the root page of the second node server is displayed but none of the css, js or images are loaded so the page doesn't look or work as it should and I see the following in the browser console...
Mixed Content: The page at 'https://example.com/node2/' was loaded over HTTPS, but requested an insecure image 'http://192.168.1.100:3000/assets/graphics/logo.png'. This content should also be served over HTTPS.
and
Failed to load resource: net::ERR_CONNECTION_CLOSED https://192.168.1.100:3000/assets/css/styles.min.css
for css and js assets... so it seems that no redirection is taking place for assets and also any links on the html page do not show the /node2/ suffix when hovered over or when clicked as the page tries to load the resource from https://example.com instead of https://example.com/node2/
Is it possible to actually do what I want in terms of reverse proxy two locations and can anyone point me in the right direction on how I can get this work as need?
Upvotes: 0
Views: 2751
Reputation: 2785
The application being loaded is set up to load assets from the server root, not with server root + /node2/
Upvotes: 0