0

what we have:
reverse-proxy server with nginx - external: 10.xx.xx.xx - internal: 192.xx.xx.1
internal server running a service on port 9010: 192.xx.xx.15
We get already the service if we connect to the proxy via https://10.xx.xx.xx/

But the goal is:
To get the service on the internal server if we connect via https://10.xx.xx.xx/internalserver. But if we set the location in the config from / to /internalserver or /inernalserver/ we only get to the default nginx index page -> to https://10.xx.xx.xx/index.html

Also important: We want to get use https://10.xx.xx.xx/internalserver but it should only be proxied to http://192.xx.xx.15:9010/ not to http://192.xx.xx.15:9010/internalserver.

Why is it not working? We tried already some rewrite commands but with no effect.

server {
    listen 80;
    return 301 https://$host$request_uri;
}

server {
    listen 443;
    server_name 10.xx.xx.xx;

    ssl_certificate            /etc/nginx/certificate.crt;
    ssl_certificate_key        /etc/nginx/certificate.key;

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    location /test/ {
            # rewrite ^/test(/.*)$ $1 break;
            proxy_pass        http://192.xx.xx.15:9010/;
}
}
Maurice
  • 1
  • 1

1 Answers1

1

This will work using rewrite:

location /internalserver {
        rewrite /internalserver/(.*) /$1  break;
        proxy_pass         http://192.xx.xx.15:9010;
        proxy_redirect     off;
        proxy_set_header   Host $host;
}

In your case you should not need rewrite at all though, just specify the exact url in proxy_pass:

location /internalserver {
  proxy_pass http://192.xx.xx.15:9010/;
}

The usage and location of / is important in both cases.

DrugsBunny
  • 11
  • 2