原创  nginx 一期配置备忘

分类:websocket 2019-12-15T10:21:29    32人阅读   
server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
	
    location / {
	

		set $root_path /usr/share/nginx/html;
		
		set $full_url '${host}${uri}';
		
		if ( $host ~* "m.weiqinxue.cn" ){
			set $root_path /opt/code/iface/mobile;
		}
		
		default_type    text/plain;
		root   $root_path;
		index  index.html index.htm;
        proxy_set_header Host $host;
	    proxy_http_version 1.1;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-real-ip $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 	    proxy_headers_hash_max_size 51200;
 	    proxy_headers_hash_bucket_size 6400;
		
	
		if ( $full_url ~* "m.weiqinxue.cn/style" ){
            proxy_pass http://localhost:81;
            break;
        }
  
		if ( $host ~* "note.weiqinxue.cn" ){
            proxy_pass http://localhost:8055;
            break;
        }
		if ( $host ~* "blog.weiqinxue.cn" ){
            proxy_pass http://localhost:5000;
            break;
        }
		if ( $host ~* "pay.weiqinxue.cn" ){
			proxy_pass http://localhost:8054;
			break;
		}

		if ( $host ~* "iface.weiqinxue.cn" ){
			proxy_pass http://localhost:10001;
			break;
		}

		if ( $host ~* "ws.weiqinxue.cn" ){
			proxy_pass http://localhost:8088;
			break;
		}

		if ( $host ~* "bs.weiqinxue.cn" ){
			proxy_pass http://localhost:8080;
			break;
		}

		if ( $host ~* "ddns.weiqinxue.cn" ){
			break;
		}
		
		if ( $host ~* "imcore.weiqinxue.cn" ){
			proxy_pass http://localhost:10003;
			break;
		}
		
				
		if ( $host ~* "mall.weiqinxue.cn" ){
			proxy_pass http://localhost:10004;
			break;
		}
    }
	
	#前端接口请求代理
	location /api {
	
		root   /usr/share/nginx/html;
		index  index.html index.htm;
        proxy_set_header Host $host;
	    proxy_http_version 1.1;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-real-ip $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 	    proxy_headers_hash_max_size 51200;
 	    proxy_headers_hash_bucket_size 6400;
		if ( $host ~* "pay.weiqinxue.cn" ){
			proxy_pass http://localhost:8054;
			break;
		}
		proxy_pass http://localhost:81/;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}


server {
    listen       83;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
	
    location / {
		root   /usr/share/nginx/html;
		index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

}


分享到: