Nginx代理同域名下前后端分离,有web端和微信端的项目

Nginx的安装、使用大家一定都会,也有很多教程,我记录一下配置
SSL使用的是阿里的免费SSL

  server {
	listen 443 ssl;
	server_name 		 XXXXXXX.com;
	ssl_certificate 	 XXXXXXX.pem;
	ssl_certificate_key      XXXXXXX.key;
		 
	client_header_timeout 120s;
	client_body_timeout 120s;
	client_max_body_size 100M;
		
	# gzip config
		gzip on;
		gzip_min_length 1k;
		gzip_comp_level 9;
		gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
		gzip_vary on;
		gzip_disable "MSIE [1-6]\.";		
	
	
	location /wxh5 {
		alias D:/Project/test/h5/;
		index index.html;
		try_files $uri $uri/ @router;	
	}
		
	location / {
		root   D:/Project/test/web;
		index  index.html;
		if (!-e $request_filename) {
			rewrite ^(.*)$ /index.html?s=$1 last;
			break;
		}
		#try_files $uri $uri/ @router;		
	}
		
	location /api{
        proxy_pass   http://localhost:8082/vote/;
	    proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
    }

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

一点点简单的说明:
alias和root的区别:在于对URI的处理方法不同。
alias是一个目录别名的定义,root则是最上层目录的定义
alias后面要用“/”结束,而root则可有可无

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值