Skip to content

Instantly share code, notes, and snippets.

@congto
Created May 3, 2017 16:58
Show Gist options
  • Save congto/0bc9cbe5dbf649ef1ff1de8fc4f3e228 to your computer and use it in GitHub Desktop.
Save congto/0bc9cbe5dbf649ef1ff1de8fc4f3e228 to your computer and use it in GitHub Desktop.
nginx.conf_multiple_upstream.md
yum install -y policycoreutils-devel
grep nginx /var/log/audit/audit.log | audit2allow -M nginx
semodule -i nginx.pp

File khai bao su dung multiple upstream

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

# user nginx;
# user root;
worker_processes  auto;
error_log /var/log/nginx/error.log;
#pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/default.d/*.conf;

events {
    worker_connections 1024;
}


http {  
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    #include /etc/nginx/conf.d/*.conf;
    upstream backends {
			server 172.16.69.21:81 ;
			server 172.16.69.22:81 ;
		}
     
    server {
        listen       80;
        server_name  nginx1;
        #root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        #include /etc/nginx/default.d/*.conf;

        location / {
	    proxy_pass http://backends;
        }
}
upstream nova-api {
        server 172.16.69.21:80;
        server 172.16.69.22:80;
    }
    server {
        listen 82;
		 location / {
         proxy_pass http://nova-api;
		 }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment