One NGINX server to 2 backend servers

p0lak nginx-forum at forum.nginx.org
Fri Feb 24 11:17:51 UTC 2017


Hello everybody,

I have installed a dedicated server for NGINX based on Ubuntu Core 

I want to define this behavior

NGINX Server (Public IP) >>> listening on port 80 >>> redirect to a LAN
Server on port 80 (http://mylocalserver/virtualhost1)
NGINX Server (Public IP) >>> listening on port 81 >>> redirect to a LAN
Server on port 80 (http://mylocalserver/virtualhost2)

My local virtualhost on my backend server is reachable (ie:
http://mylocalserver/virtualhost1)
but my second virtualhost is not reachable (ie:
http://mylocalserver/virtualhost2)

it is like the network port is closed but my firewall is accepting the
flow.

here is my configuration if you have any idea why my second virtualhost is
not reachable 

##NGINX.CONF##

user www-data;
worker_processes  2;				
events {
	worker_connections  19000;		
}
worker_rlimit_nofile    40000;		
http {
  
client_body_timeout      5s; 
client_header_timeout    5s;
keepalive_timeout       75s; 
send_timeout            15s; 
gzip on;
gzip_disable "msie6";
gzip_http_version  1.1;			
gzip_comp_level    5;			
gzip_min_length    256;			
gzip_proxied       any;			
gzip_vary          on;			
gzip_types					
      application/atom+xml
      application/javascript
      application/json
      application/rss+xml
      application/vnd.ms-fontobject
      application/x-font-ttf
      application/x-web-app-manifest+json
      application/xhtml+xml
      application/xml
      font/opentype
      image/svg+xml
      image/x-icon
      text/css
      text/plain
      text/x-component;

    client_max_body_size       100k; 
    client_body_buffer_size    128k;
    client_body_in_single_buffer on;
    client_body_temp_path      /var/nginx/client_body_temp;
    client_header_buffer_size    1k;
    large_client_header_buffers  4 4k;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

#PROXY.CONF#
proxy_redirect          on;
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_hide_header       X-Powered-By;
proxy_intercept_errors on;
proxy_buffering on;


proxy_cache_key "$scheme://$host$request_uri";
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache:10m inactive=7d
max_size=700m;


#VIRTUALHOST 1
server {
    listen   80;
    server_name virtualhost1;
}

#VIRTUALHOST 2
server {
    listen   81;
    server_name virtualhost2;
}


Could you please help me regarding my issue,

Thanks so much,

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,272606,272606#msg-272606



More information about the nginx mailing list