Welcome! Log In Create A New Profile

Advanced

reverse proxy with TLS termination and DNS lookup

Posted by squonk 
reverse proxy with TLS termination and DNS lookup
September 03, 2016 02:05PM
hi all..

I am trying to configure a reverse proxy which redirects a URL of the form:

https://mydomain.com/myapp/abcd/...

to:

http://myapp:5100/abcd/...

with DNS resolution of "myapp" to an IP address at runtime.

My current configuration file is:

server{
listen 80 default_server;
server_name mydomain.com;
return 301 https://www.mydomain.com$request_uri;
}

server{
listen 443 ssl default_server;
server_name mydomain.com;
<ssl setup.. works ok>;

resolver 123.4.5.6 valid=60s; // DNS name server.. 'nslookup myapp' does work
set app_upstream http://myapp:5100;
location /myapp/ {
rewrite ^/myapp/(.*) /$1 break;
proxy_pass $app_upstream;
}
}

When i try:

https://mydomain.com/myapp/

it resolves to:

http://myapp/

but the log shows that the port isn't appended. I would prefer it if the caller didn't have to know the port. I could iterate, but don't have enough experience to say whether the overall approach is consistent with Nginx best practice and i need to proxy servers other than myapp so any feedback would be appreciated.

thanks!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 100
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