i have a "little" NGinx Problem.
I have Multiple Webapps and i will publish it through the NGINX Reverseproxy.
Under 1 URL i will publish multiple Webapps:
so:
https://Reverseproxy/webappA
https://Reverseproxy/webappB
https://Reverseproxy/webappC
This work so:
https://Reverseproxy/webappA --> redirect to http://www.webappaWebserver.com/webappA
--> And naturally this works fine ;-).
But with my Webapp B i have a challenge. I must find a way to bring the follow Scenario to work:
https://Reverseproxy/webappB --> redirect to http://www.webappBWebserver.com/
--> And this doesn´t work becuse the Subsite (after the Slash) is not there. But i can´t made URL Webserverchanges on this Webserver.
So how i can get this get running with this Constellation?
Here are my Config for the Reverseproxy:
location /appb {
proxy_pass http://10.254.1.41:80;
include /etc/nginx/conf.d/proxy.conf;
}
proxy.conf:
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
### Proxy headers
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Forwarded $proxy_add_forwarded;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
### Proxy timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
~
Thank you very much for your help.
Replace page_name with webappA,webappB or webappC .
Replace example.com with your subdomain.
location /page_name/ {
rewrite ^([^.]*[^/])$ $1/ permanent;
sub_filter_once off;
sub_filter_types *;
sub_filter /_elderjs /page_name/_elderjs;
proxy_ssl_verify off;
proxy_set_header Host "example.com";
proxy_set_header X-Forwarded-Host "";
proxy_set_header X-Forwarded-For "";
proxy_set_header Accept-Encoding "";
proxy_set_header Cookie "";
proxy_ssl_server_name on;
proxy_pass https://example.com/;
proxy_redirect ~^(http://[^/]+)(/.*)$ https://$http_host$2;
}
Its works for me ;). Hope this answer solves your problem.