Nginx reverse proxy

Are you having trouble getting Virtual Radar Server installed and running? If so then this is the place to ask about it.
Post Reply
joma
Posts: 2
Joined: Wed Jan 20, 2016 4:46 pm

Nginx reverse proxy

Post by joma » Thu Jan 21, 2016 8:06 pm

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.

joma
Posts: 2
Joined: Wed Jan 20, 2016 4:46 pm

Re: Nginx reverse proxy

Post by joma » Thu Jan 21, 2016 10:46 pm

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!

agw
Posts: 2248
Joined: Fri Feb 17, 2012 3:20 am

Re: Nginx reverse proxy

Post by agw » Thu Jan 21, 2016 11:17 pm

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".

ssuttner
Posts: 8
Joined: Wed Dec 30, 2015 8:39 am
Contact:

Re: Nginx reverse proxy

Post by ssuttner » Thu Mar 31, 2016 8:02 pm

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

dsfh2992
Posts: 156
Joined: Tue Oct 06, 2015 9:57 pm

Re: Nginx reverse proxy

Post by dsfh2992 » Mon Apr 18, 2016 7:56 pm

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?

agw
Posts: 2248
Joined: Fri Feb 17, 2012 3:20 am

Re: Nginx reverse proxy

Post by agw » Tue Apr 19, 2016 12:21 am

From memory it's involved in working out the correct redirect address when a browser asks for <your ip address>/VirtualRadar.

Post Reply