栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

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

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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则可有可无

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/945302.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号