reverse proxy with TLS termination and DNS lookup

squonk nginx-forum at forum.nginx.org
Sun Sep 4 09:10:11 UTC 2016


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!

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,269375,269375#msg-269375



More information about the nginx mailing list