nginx redirect proxy
- by andrew
I have a web app running on a nginx server on local ip 192.168.0.30:80
I have this in my etc/hosts
127.0.0.1 w.myapp.in
If someone accesses my app using a "w" subdomain, it shows a webdav interface, otherwise it runs normally
(for example, someone calls http://myapp.in , it goes into the app, and http://w.myapp.in goes into webdav interface - this is done within the app, nginx has nothing to do with it)
Because I don't have a dns or anything like that, users must access the app by ip. A problem appears if someone wants to access the webdav interface, because you cannot access the app by a subdomain - unless you write a line in your local hosts file, which is not a solution)
A possible solution
If it's possible to setup the nginx server so that if someone calls http://192.168.0.30 (on port 80), it goes normally into the app, but if a user tries to access say http://192.168.0.30:81 (another defined port) it redirects internally to w.myapp.in, and the app sees the subdomain
Given the app, can this be done? If yes, what should I put in the nginx config file?
And if you guys think of a better solution, I'm open to any.