0

My nginx.conf

location /admin/ {
                proxy_buffering off;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass https://myproxydomain.com:3000;

      }

I would like to have all my pages from mentioned proxy_pass url, as https://subdomain.example.com/admin/sign

But the moment, I was trying to access signin page (signin page which is in proxy_pass url), it is serving as https://subdomain.example.com/sign

Any inputs would be appreciated!

  • Please clarify what you mean by redirect here. – Tero Kilkanen Feb 08 '18 at 22:05
  • HTTP redirection. Way to point one domain or address to another. – Sikandar Khan Feb 09 '18 at 12:40
  • So do you mean that when you try the `/admin/sign` URL, there is a redirect to `/sign`? That is not caused by the configuration you have above, but by the application you are running. – Tero Kilkanen Feb 20 '18 at 07:37
  • @TeroKilkanen, sorry for my poor english. Please read the question again, I edited it. – Sikandar Khan Mar 03 '18 at 13:46
  • The question is still a bit unclear.. Do you mean that the URLs from the HTML files provided by ´proxy_pass` server contain `https://subdomain.example.com/sign`? If that is the case, then you need to change the application there, nginx does not support changing the HTML output from `proxy_pass` servers. – Tero Kilkanen Mar 03 '18 at 14:21
  • Okay. I I will try again 1. For specific location (i.e, /admin/) I am adding proxy_pass with certain url 2. Now ideally, all pages from proxy_pass, prepend with this location variable. I would like to prepand my location variable (i.e, /admin/) to every request that I make on proxy_pass – Sikandar Khan Mar 03 '18 at 14:31
  • Please look at section :2 here at specified URL https://www.liaohuqiu.net/posts/nginx-proxy-pass/ – Sikandar Khan Mar 03 '18 at 14:34

1 Answers1

0

Would this work:

location /admin {
    proxy_buffering off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass https://myproxydomain.com:3000/admin/;# 
}

If that does not work, then you can use a regex capture:

location ~ /admin(.*) {
    ...
    proxy_pass https://myproxydomain.com:3000/admin$1;
}
Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • both didn't work for me. thanks in advance. I have a point to make here, proxy_pass https://myproxydomain.com:3000/admin/; This URL doesn't work exist right! . Because /admin/ we are prepending from NGINX location directive. – Sikandar Khan Mar 03 '18 at 17:29