Welcome! Log In Create A New Profile

Advanced

ProxyPass domain to subdirectory

Posted by kazanka101 
ProxyPass domain to subdirectory
April 15, 2021 11:27AM
Hello,

Currently I have a website sitting at "site1.domain.com" which I would like to proxy pass to another host like "domain.com/site1/" reason for this is I have multiple sites on separate systems and want to keep them all appended this way.

My problem however is when loading "domain.com/site1/" it spins as it's trying to load other directories which are loading from site1.domain.com without the appended /site1/.

I realize Nginx only proxies specific requests yet is there a way to have this work and proxy everything from "site1.domain.com" to include subdirectories and files to "domain.com/site1/".

My config is...

location /site1/ {
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_set_header X-Forwarded-Proto $scheme;
proxy_pass http://site1.domain.com/;
proxy_read_timeout 90;
proxy_redirect http://site1.domain.com/ https://domain.com;
}


I've tried using "rewrite /site1/([^/]+) /$1 break;" after location but nothing seems to be working.

Ideally I've done this by adding each location its specifying and then using a rewrite but I'd rather have it all in 1 rule as I have multiple other sites I plan to add to this.

Any help would be appreciated!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 113
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready