I got three web servers:
app1 - on local server with nginx. this app listens 127.0.0.1:8080
app2 - on 10.7.0.2:80
app3 - on 10.7.0.10:80
I wan to config NGINX to proxy this three apps on same domain, but different paths:
app1 - https://my.domain.com/something/
app2 - https://my.domain.com/
app3 - https://my.domain.com/nothing/
I have wildcard SSL certificate for *.domain.com
Here is my config:
upstream app2 {
server 10.7.0.2:80;
}
upstream app3 {
server 10.7.0.3:80;
}
server {
listen 0.0.0.0:80;
server_name my.domain.com;
server_tokens off;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name my.domain.com;
access_log logs/my.domain.com main;
ssl_certificate /etc/nginx/certs/my.domain.com/cert.txt;
ssl_certificate_key /etc/nginx/certs/my.domain.com/private.txt;
location /something {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/;
include proxy_params;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://app2;
include proxy_params;
}
location /nothing {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://app3;
include proxy_params;
}
}
But this config works good only for app2.
When i'm trying to open https://my.domain.com/something/ I see this in browser console:
GET https://my.domain.com/styles.css [HTTP/1.1 404 Not Found 265ms]
GET https://my.domain.com/static/js/main.f726536f.js [HTTP/1.1 404 Not Found 432ms]
GET https://my.domain.com/static/css/main.967cebd1.css [HTTP/1.1 404 Not Found 432ms]
Loading failed for the <script> with source “https://my.domain.com/static/js/main.f726536f.js”.
Whats wrong?