Configuring multi-server nginx proxy

Found nginx> conf directory nginx.conf 

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
      '$status $body_bytes_sent "$http_referer" '
     '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    65 keepalive_timeout; 

    #gzip  on;

    # /var/log/nginx/access.log main access_log; 

    upstream load balancing for illustration purposes reference # https://blog.csdn.net/caijunsen/article/details/83002219 
    upstream psjcserver { 
	    Server 192.168.20.81:8091 ; 
	    #server 172.18.253.44:8083; 
    } 

    # conf conf.d directory configuration read 
    the include "E:. /nginx-1.17.2/conf/conf.d / * the conf"; 


}

  

Create a conf.d directory nginx> conf directory (conf.d used to store multiple server configuration)

Create a directory admin.conf, it is identified for the following * conf FIG.

  

 

Production admin.conf code management server admin

{Server 
	the listen 80; 
	server_name 127.0.0.1; 

	LOCATION / { 
		the root "E: / ADMIN"; 
		index index.html index.htm; 
	} 

	LOCATION / ADMIN / { 
	    # matches the rewrite localhost / admin converted to HTTP: // psjcserver 
	    the rewrite ^ . + ADMIN /?(.*)$ / $. 1 BREAK; 
	    # proxy_pass agent disposed excuse 
		proxy_pass http: // psjcserver; 
		# if provided with a back-end server is really similar anti-theft chain according to route or http request header field host or a determining function, and if nginx reverse proxy host layer does not override the request header field will cause the request fails, the error message 400 
		proxy_set_header the host $ HTTP_HOST; 
		$ autoindex ON; 
	} 

	LOCATION {/favicon.ico 
		the root HTML; 
	} 

	error_page 500 502 503 504 /50x.html; 
	LOCATION /50x.html = {  
		the root HTML;
	} 
}

  

 

Guess you like

Origin www.cnblogs.com/hpx2020/p/11239922.html