New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Nginx proxy_pass root directory vs sub-directory
Hey guys,
I've setup Nginx on my RPi & I'm streaming a live cam, among other things. I'm proxying from one of my VPS to the home RPi Nginx.
My /directory/ proxy is working just fine, i.e.
location /folder/ { proxy_pass http://homeserver.domain.com:11111/directory/; }
However if I try to redirect the root direct, rather than a sub-folder, it's not working:
location / { proxy_pass http://homeserver.domain.com:11111/directory/; }
As this isn't working, currently I've setup a redirect from the root to the folder
location = / { return 301 /directory/; }
This is working fine, but I'd like to eliminate the /folder/. All the examples/discussion I see revolved around sub-folders, I've created many re-directs/proxy's in the past but always based on sub-folders, not the primary directory.
Anyone have any insight that can be useful? Thanks!
Comments
Yeah it can get finicky if you're not doing /directory/ to /folder/. I think you may have to use a rewrite but I'm not sure if it's transparant or not when followed by the proxy_pass (you'll have to test to see). Something like:
location / { rewrite ^/$ /directory/ break; proxy_pass http://homeserver.domain.com:1111; }
or maybe
rewrite /(.*)$ /directory/$1 break; proxy_pass http://homeserver.domain.com:1111;
Haven't tested these to see if they're even valid, but I'm sure you get the idea - it may be worth giving a shot to see if they work and whether they do the rewrite transparantly (which seems to be what you're looking for). Maybe someone will come along with a better/cleaner solution though.
Cheers, I'll give that a try, weird that Nginx hates proxying the primary directory.
Have never encountered such an issue with nginx, it's perfectly able to proxy root locations to wherever that be.
Please post the complete relevant part of your nginx configuration, and explain what you mean by "not working" (= what do you observe ? server crash ?)