Commit 9cd63f5b by zhangxingmin

push

parent 91dae4fc
...@@ -60,5 +60,5 @@ RUN echo "https://mirrors.aliyun.com/alpine/v3.22/main/" > /etc/apk/repositories ...@@ -60,5 +60,5 @@ RUN echo "https://mirrors.aliyun.com/alpine/v3.22/main/" > /etc/apk/repositories
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone echo "Asia/Shanghai" > /etc/timezone
EXPOSE 6666 EXPOSE 6699
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]
server { server {
listen 6666; listen 6699;
server_name 139.224.145.34; server_name 139.224.145.34;
# 处理前端静态资源(Vue应用) # 处理前端静态资源(Vue应用)
location / { location / {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.html index.htm; index index.html;
try_files $uri $uri/ /index.html; try_files $uri $uri/ /index.html; # 处理Vue路由history模式
if ($request_method = OPTIONS) {
# 处理OPTIONS预检请求
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000; add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0; add_header 'Content-Length' 0;
return 204; return 204;
} }
# 限制允许的HTTP方法
limit_except GET POST PUT DELETE OPTIONS { limit_except GET POST PUT DELETE OPTIONS {
deny all; deny all;
} }
...@@ -27,28 +24,11 @@ server { ...@@ -27,28 +24,11 @@ server {
# 代理后端API请求 - 使用更具体的路径 # 代理后端API请求 - 使用更具体的路径
location /api/ { location /api/ {
proxy_buffer_size 1024k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
proxy_buffers 16 1024k; #proxy_buffers缓冲区,网页平均在32k以下的设置
proxy_busy_buffers_size 2048k; #高负荷下缓冲大小(proxy_buffers*2)
proxy_temp_file_write_size 2048k; #设定缓存文件夹大小,大于这个值,将从upstream服务器传
proxy_pass http://139.224.145.34:9002/; proxy_pass http://139.224.145.34:9002/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 缓冲区配置
proxy_buffer_size 1024k;
proxy_buffers 16 1024k;
proxy_busy_buffers_size 2048k;
proxy_temp_file_write_size 2048k;
# 处理OPTIONS预检请求(确保后端API也支持CORS)
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
} }
# 可能需要代理其他后端服务 # 可能需要代理其他后端服务
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment