nginx配置
Opened this issue · 0 comments
Sandra310 commented
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_static on;
server
{
listen 80;
server_name ~^(.+)?\.xx\.com$;
location / {
root /home/$1;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_static on;
# lingshouyun CMS负载分流
upstream b2b-cb_xx_local {
# 当前为预发布
server xxb2b-node-client-yufa.lsy-sys.svc.lf09.n.xx.local weight=10 max_fails=2 fail_timeout=30s;
# 线上地址如下:后面提供
}
# 跟b shangcheng 相关,对外能独立提供部署的web应用。比如:me 嵌入的小京玲提报表单
server
{
listen 80;
server_name b2b-external-module.xx.com beta-b2b-external-module.xx.com;
location / {
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,web-token,app-token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
# # 预发配置
# root /home/beta-b2b-external-module;
# 生产配置
root /home/b2b-external-module;
index index.html index.htm;
try_files $uri $uri/ /index.html;
add_header Cache-Control no-store;
}
}
# 主域,对应的基座应用
server
{
listen 80;
server_name b2b.xx.com beta-b2b.xx.com;
access_log /export/Logs/nginx/nginx_access.log main;
error_log /export/Logs/nginx/nginx_error.log warn;
add_header ser-main "ngx-c1";
# add_header Cache-Control;
# 首页代理到 lingshouyun CMS
location = / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://b2b-cb_xx_local/user/pc;
}
# 跳转浏览器下载推荐页
location /browser {
# 预发
# root /home/beta-b2b;
# 生产
root /home/b2b;
index browser.html;
try_files $uri $uri/ /browser.html;
}
# 首页CMS部分异步
location ^~ /api/ {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://b2b-cb_xx_local;
}
# 成长中心文件转发
location /omni-growth-center/ {
proxy_pass http://storage.xx.local/;
}
location / {
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,web-token,app-token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
root /home/b2b;
index index.html index.htm;
try_files $uri $uri/ /index.html;
add_header Cache-Control no-store;
}
}
# 子应用域名
server
{
listen 80;
server_name ~^(.+)?\.xx\.com$;
add_header ser "ngx-c2";
access_log /export/Logs/nginx/nginx_access.all.log main;
error_log /export/Logs/nginx/nginx_error.all.log warn;
location / {
# add_header Cache-Control;
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,web-token,app-token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
# 禁止微应用在浏览器中独立访问
valid_referers *.xx.com xx.com;
if ($invalid_referer) {
rewrite ^/ https://b2b.xx.com redirect;
}
root /home/$1;
index index.html index.htm;
try_files $uri $uri/ /index.html;
add_header Cache-Control no-store;
}
}