Page 1 of 1

Nginx reverse proxy

Posted: Thu Jan 21, 2016 8:06 pm
by joma
Hi,

It's possible to use Nginx as Virtual Radar reverse proxy?

I tried the follow nginx host configuration:

Server {
listen 80;

index index.html index.htm index.php;

server_name radar.jorgemota.pt;

location / {

proxy_pass http://127.0.0.1:8085/VirtualRadar;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;

}
}

without success. The url is redirected to http://radar.jorgemota.pt//desktop.html but without any content.

Thanks in Advance.

Re: Nginx reverse proxy

Posted: Thu Jan 21, 2016 10:46 pm
by joma
This configuration works!

server {
listen 80;

index index.html index.htm index.php;

server_name radar.jorgemota.pt;

location / {

proxy_pass http://127.0.0.1:8085/VirtualRadar/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;

}
}

A little front slash makes all the diference!

Re: Nginx reverse proxy

Posted: Thu Jan 21, 2016 11:17 pm
by agw
You may also need to tell VRS that it's behind a reverse proxy by going into Tools | Options | Web Site and setting the proxy type to "Reverse".

Re: Nginx reverse proxy

Posted: Thu Mar 31, 2016 8:02 pm
by ssuttner
Maybe a better solution:
- first of all figure out if mobile browser or not
- after this open mobile or desktop page via nginx reverse proxy

Code: Select all

	set $mobile_request false;
	if ($http_user_agent ~* '(Mobile|WebOS)') {
		set $mobile_request true;
	}

	if ($mobile_request = true) {
	    	rewrite ^/vrs/$ /vrs/VirtualRadar\mobile.html permanent;
	    	rewrite ^/vrs$ /vrs/VirtualRadar\mobile.html permanent;
	}
	if ($mobile_request = false) {
	    	rewrite ^/vrs/$ /vrs/VirtualRadar\desktop.html permanent;
	    	rewrite ^/vrs$ /vrs/VirtualRadar\desktop.html permanent;
	}
	location /vrs {
	  	rewrite 		/vrs/(.*) /$1 break;
		access_log 		/var/log/nginx/vrs.access.log;
		error_log 		/var/log/nginx/vrs.error.log;
	  	proxy_pass 		http://localhost:8082;
		proxy_redirect 		off;
		proxy_set_header 	Host $host;
		proxy_set_header 	X-Forwarded-For $proxy_add_x_forwarded_for;
	}
now you can open your VRS page via http://www.yourDomain/vrs

Re: Nginx reverse proxy

Posted: Mon Apr 18, 2016 7:56 pm
by dsfh2992
agw wrote:You may also need to tell VRS that it's behind a reverse proxy by going into Tools | Options | Web Site and setting the proxy type to "Reverse".
What does this do?

Re: Nginx reverse proxy

Posted: Tue Apr 19, 2016 12:21 am
by agw
From memory it's involved in working out the correct redirect address when a browser asks for <your ip address>/VirtualRadar.

Re: Nginx reverse proxy

Posted: Mon Mar 16, 2020 4:44 am
by loplo
Did anyone manage to pass the external ip to VRS, so you can see the IP that's accessing the radar?

Re: Nginx reverse proxy

Posted: Tue Apr 07, 2020 8:36 am
by metalXtractor
I bumping this up because the mentioned solutions don't fully work.

In my case the access url is: vradar.domain.com
The internal url is: http://192.168.1.44:8888/

Here are my findings:

This was the originally proposed solution:

Code: Select all

location / {
proxy_pass http://192.168.1.44:8888/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
This will only work if someone enters the VirtualRadar in the URL for example: https://vradar.domain.com/VirtualRadar/
Which is just ugly but works.

I have found a solution for this:

Code: Select all

location ~ ^/(.*)$ {
proxy_pass http://192.168.1.44:8888/$1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
This will work however none of the aircraft pictures will show up anymore. I guess it breaks the external feed somehow. Corrections are welcome.