原创 

nginx 一期配置备忘

分类:websocket    267人阅读    IT小君  2019-12-15 10:21
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;
    }

}


点击广告,支持我们为你提供更好的服务

HTML5现代家居装潢公司网站模板

js+css3抽奖转盘旋转点餐代码

css+js实现的颜色渐变数字时钟动画特效

响应式时尚单品在线商城网站模板

网页设计开发公司网站模板

canvas炫酷鼠标移动文字粒子特效

html5图标下拉搜索框自动匹配代码

中小型创意设计服务公司网站模板

HTML5数字产品服务公司网站模板

html5 svg夜空中星星流星动画场景特效

html5 canvas彩色碎片组合球形旋转动画特效

响应式咖啡饮品宣传网站模板

css鼠标跟随文字模糊特效

小众时尚单品在线电子商务网站模板

现代时尚家具公司网站模板

html5 canvas进度条圆环图表统计动画特效

有机水果蔬菜HTML5网站模板

响应式太阳能能源公司网站模板

HTML5 Canvas竖直流动线条背景动画特效

jQuery右端悬浮带返回顶部特效

点击广告,支持我们为你提供更好的服务
 工具推荐 更多»
点击广告,支持我们为你提供更好的服务