Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Reverse Proxy URL Without Base URL

$
0
0
Hey Guys -

I use Nginx in my home lab as a reverse proxy for multiple locally hosted pages as well as add an SSL layer. Although I've successfully been able to configure most of my pages in the past, I'm having trouble with this one. Below are details followed by what I've tried with results…

Details
- Trying to forward URL which is hosted on port 80 of a LAN system - "http://prtgsvr" (prtgsvr is a hostname)
- Wish to rewrite it to https://mydomain.com/prtg
- Application does not offer option to configure a base URL
- Browsing to "http://prtgsvr" simply goes to "http://prtgsvr/index.html"

Attempt #1
location /prtg {
rewrite /prtg(.*) /$1 break;
proxy_pass http://prtgsvr;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Connection "";

Result #1
Page tries to load until it times out with 404 which then shows it was trying to go to "mydomain.com/index.html"

Attempt #2
location /prtg/ {
proxy_pass http://prtgsvr/;
proxy_redirect http://prtgsvr/ http://mydomain.com/prtg/;
proxy_set_header Host $host;
proxy_set_header Referer $http_referer;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}

Result #2
Redirected to "mydomain.com/index.html" and displayed 404 since I do not have an index.html in the root. I also tried this using "https" on the proxy_redirect line with the same results.

If it Helps...
When searching for a solution, I did find the below config which someone used with the same application, however; it doesn't redirect it to a URL Base:

upstream prtgaero-rs {
server prtgaero.palmbeach.k12.fl.us;
keepalive 32;
}
server {
listen 443 ssl;
server_name prtgaero01.palmbeach.k12.fl.us
ssl on;
ssl_certificate /etc/nginx/ssl/prtgaero01.crt;
ssl_certificate_key /etc/nginx/ssl/prtgaero01.pem;
location / {
proxy_pass http://prtgaero-rs;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}

Thanks Guys

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>