0

I am running Nginx on Linux and attempting to run it as a reverse proxy. However, when I try and set a subdomain to proxy to a program I have running on another server it returns a 404 error. The subdomain I am using is vrs.thomp.site, and the internal address of the program is 192.168.1.190/virtualradar

I found this line in my error logs and I think its the issue I just don't know how to fix it, notice how it's doing "VirtualRadarVirtualRadar"

"GET /VirtualRadarVirtualRadar/desktop.html HTTP/1.0

One thing that is odd is that normally the website will redirect you to desktop.html and it does that remotely but returns the 404 error.

here is my config,

server_name vrs.thomp.site;
proxy_buffers 8 1024k;  
proxy_buffer_size 1024k;
access_log  /var/log/nginx/vrs.access.log;
error_log   /var/log/nginx/vrs.error.log debug;
location / {
    proxy_buffering off;
    proxy_read_timeout          1m;
    proxy_connect_timeout       1m;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host:$server_port;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass                  http://192.168.1.190:80/virtualradar/;
    proxy_redirect default;
    proxy_cookie_path /virtualradar/ /;
    
}
  • With `proxy_set_header Host $host;` you pass the host header to upstream (another server) but is that really what the upstream wants? Did you try `proxy_set_header Host "192.168.1.190";`? – Lex Li Aug 13 '22 at 00:10
  • @LexLi Doing that just sets the address as 192.168.1.190 so doing it remotely wont work because I need it to proxy to an internal server of that address. – ryan_thomp Aug 14 '22 at 03:38
  • `http://192.168.1.190:80/virtualradar/;` should be `http://192.168.1.190/virtualradar;` – djdomi Aug 14 '22 at 04:47
  • Isn't what you wanted forwarding traffic on `vrs.thomp.site` to an internal upstream server at `http://192.168.1.190:80/virtualradar/`? If so, `proxy_set_header Host "192.168.1.190";` ensures the upstream server only receives HTTP requests whose `Host` header is `192.168.1.190` which is very common in reverse proxy setup (many upstream servers dislike `proxy_set_header Host $host;`. I don't know why you said "Doing that just sets the address as 192.168.1.190 so doing it remotely wont work" but anyway only you know what upstream server is being used so only you can help yourself. – Lex Li Aug 14 '22 at 06:34

0 Answers0