feat:修正nginx配置

This commit is contained in:
1708-huayu 2024-12-26 19:38:06 +08:00
parent a760fbfb1f
commit cf8fdda4b6
1 changed files with 16 additions and 4 deletions

View File

@ -17,14 +17,14 @@ http {
server {
listen 3001;
# 设置允许跨域的域,* 表示允许任何域,也可以设置特定的域
# 设置允许跨域的域,* 表示允许任何域,也可以设置特定的域,has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.
add_header 'Access-Control-Allow-Origin' '*';
# 允许的方法
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
# 允许的头信息字段
add_header 'Access-Control-Allow-Headers' 'User-Agent,Keep-Alive,Content-Type';
add_header 'Access-Control-Allow-Headers' 'User-Agent,Keep-Alive,Content-Type,Authorization,Origin' always;
# 缓存时间
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Access-Control-Max-Age' 1728000 always;
# 预检请求的处理
if ($request_method = 'OPTIONS') {
return 204;
@ -43,6 +43,10 @@ http {
# try_files $uri $uri/ =404;
}
location ^~ /todo-server/ {
# 预检请求的处理
if ($request_method = 'OPTIONS') {
return 204;
}
# rewrite ^/todo-server/(.*)$ /$1 break;
proxy_pass http://huayu-platform-todo:8092/;
proxy_set_header Host $http_host;
@ -52,6 +56,10 @@ http {
client_max_body_size 100M;
}
location ^~ /security-server/ {
# 预检请求的处理
if ($request_method = 'OPTIONS') {
return 204;
}
# rewrite ^/security-server/(.*)$ /$1 break;
proxy_pass http://huayu-platform-security:8091/;
proxy_set_header Host $http_host;
@ -62,6 +70,10 @@ http {
}
location /task/ {
# 预检请求的处理
if ($request_method = 'OPTIONS') {
return 204;
}
rewrite ^/task/(.*)$ /task/$1.html break;
}
# 静态文件缓存配置