代码改变世界

Backend Serverside Programing (Nginx)

2022-05-29 09:19  AndrewCja  阅读(43)  评论(0编辑  收藏  举报
upstream auth.backend {
server 172.18.4.197:10000;
server 172.18.4.198:10000;
}

map $http_origin $cors_list {
default 0;
~127.0.0.1 $http_origin;
~www.aihomeset.com $http_origin;
~aihomeset.com $http_origin;
}

server {
listen 80;
listen 443 ssl;
server_name service.aihomeset.com;

ssl_certificate /usr/local/nginx/conf/cert/6731419__aihomeset.com.pem;
ssl_certificate_key /usr/local/nginx/conf/cert/6731419__aihomeset.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on;

#error_page 500 501 502 503 504 /5xx.html;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,X-Token';
add_header Access-Control-Allow-Origin $cors_list;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Max-Age 86400;
 
if ($request_method = 'OPTIONS') {
return 204;
}

location /auth/ {
proxy_pass http://auth.backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#proxy_cookie_path / "/; httponly; secure; SameSite=None";
}

location / {
root /home/andrew/dGuanWang;
}
}


 
 
 
 
server {
listen 80 default_server;
listen 443 default ssl;
server_name 127.0.0.1 aihomeset.com www.aihomeset.com 47.100.77.229 47.102.116.250;
if ($request_uri ~* home|history|recruiment|about) {
rewrite (.*) https://www.aihomeset.com;
}

ssl_certificate /usr/local/nginx/conf/cert/6731419__aihomeset.com.pem;
ssl_certificate_key /usr/local/nginx/conf/cert/6731419__aihomeset.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on;

if ($request_method = 'OPTIONS') {
return 204;
}

location / {
root /home/andrew/dGuanWang;
}
}