0

I currently am working on configuring an nginx reverse proxy for the esxi html5 web client. I have seen two reported working configs.

There is this one:

 server {
 listen 443 ssl;
 server_name vmware.xxxxxxxxxx.org;
 location / {
 proxy_pass https://192.168.xxx.xxx/;
 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection “upgrade”;
 }

And this one:

location ^~ /vhost1 { # https://nginxserveraddress/vhost1 (will take you here)
    proxy_pass              https://serveripaddr/ui;
    proxy_http_version      1.1;
    proxy_set_header        Upgrade $http_upgrade;
    proxy_set_header        Connection "Upgrade";
    proxy_read_timeout      86400;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-Server $host;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        Authorization "";
    proxy_redirect          off;
}

I have successfuly proxyed subdomain.domain.com with the "exact" same proxy config it fails to proxy when I use domain.com/ui

This Works:

server {
listen 443 ssl;

server_name subdomain.domain.com;

ssl on;
ssl_certificate /etc/ssl/certs/ssl-bundle.crt;
ssl_certificate_key /etc/ssl/private/server.key;

location / {

        proxy_pass          https://ip/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout      86400;
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-Server $host;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        Authorization "";
        proxy_redirect          off;
}
}

But this does not:

server {
listen 443 ssl;
server_name domain.com;


location /ui {
        proxy_pass          https://ip/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout      86400;
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-Server $host;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        Authorization "";
        proxy_redirect          off;
    }
}

The second unconfirmed working script apparently does what I want, but it doesn't work for me, and the dev of application reported the same thing.

[Update] So it does sort of work, It takes me to log in screen, but still can't access the files in the root directory even tho I proxy the base of the webroot in my proxy_pass config. Therefor location has to be / not /ui. And to make / work, I need to use a subdomain, because I already have a location / in my main domain.

I hope that makes sense...

Example:

I used this to proxy webroot of server:

location /ui {

  proxy_pass              https://192.168.*.*:443/;

Instead of

location /ui {

  proxy_pass              https://192.168.*.*:443/ui;

I noticed this with another application as well. Specifically deluge will not proxy domain.com/deluge

but works via deluge.domain.com/

I have kind of given up, as I got a wildcard SSL cert and just decided to live with sub-domains and that not everything works via domain.com/path proxypass.

But I would like to know why, and perhaps work on figuring it out anyway.

FreeSoftwareServers
  • 515
  • 1
  • 8
  • 26
  • A big reason for me not using subdomains is my SSL is only valid for domain.com, but as I read it is still encrypted over ssl with "invalid" ssl certs, so its not that it won't work, but its not perfect and I want to understand why – FreeSoftwareServers Jan 28 '16 at 06:59
  • Please clearly state what works and what doesn't. Please show all relevant configs, and `curl -I ` output etc. – gxx Feb 04 '16 at 06:49

0 Answers0