Dynamic Proxy_pass based on subdirectory
November 28, 2016 07:01AM
hello people

been slamming my head off a wall for some time with this config... i have more of an apache background but persevering with NGINX for this project!

basically, I have created a simple reverse proxy to serve http sites as https, and it works very well using the following config

location /subdirectory/ {
sub_filter '=/"' '="'; #remove /
sub_filter_once off;
proxy_pass http://subdirectory.domain.com/;
}

what i was hoping to do was expand this with regex

location ~* ^/(.*)/$ {
sub_filter '=/"' '="'; #remove /
sub_filter_once off;
proxy_pass http://$1.domain.com/;
}

but this returns 502 bad gateway.

have tried various configs, and cannot get this to resolve properly at all...

fingers crossed for some insight :)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 298
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready