3 changed files with 37 additions and 47 deletions
@ -1,51 +1,35 @@ |
|||||
worker_processes 1; |
server { |
||||
|
listen 5000; |
||||
events { |
server_name _; |
||||
worker_connections 1024; |
client_max_body_size 20M; |
||||
} |
|
||||
|
location / { |
||||
http { |
root /usr/share/nginx/html; |
||||
include mime.types; |
try_files $uri $uri/ /index.html; |
||||
default_type application/octet-stream; |
index index.html; |
||||
|
|
||||
sendfile on; |
add_header 'Access-Control-Allow-Origin' '*'; |
||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
||||
server { |
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
||||
listen 5000; |
if ($request_method = 'OPTIONS') { |
||||
server_name _; |
add_header 'Access-Control-Max-Age' 1728000; |
||||
client_max_body_size 20M; |
add_header 'Content-Type' 'text/plain charset=UTF-8'; |
||||
|
add_header 'Content-Length' 0; |
||||
# 静态资源和前端页面 |
return 204; |
||||
location / { |
|
||||
root /usr/share/nginx/html; |
|
||||
try_files $uri $uri/ /index.html; |
|
||||
index index.html; |
|
||||
|
|
||||
# CORS |
|
||||
add_header 'Access-Control-Allow-Origin' '*'; |
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
|
||||
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; |
|
||||
} |
|
||||
} |
} |
||||
|
} |
||||
|
|
||||
# 代理 API 请求到后端容器 |
location /admin-api/ { |
||||
location /admin-api/ { |
proxy_pass http://alert-backend:48080; |
||||
proxy_pass http://alert-backend:48080; |
proxy_set_header Host $host; |
||||
proxy_set_header Host $host; |
proxy_set_header X-Real-IP $remote_addr; |
||||
proxy_set_header X-Real-IP $remote_addr; |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
proxy_set_header X-Forwarded-Proto $scheme; |
||||
proxy_set_header X-Forwarded-Proto $scheme; |
} |
||||
} |
|
||||
|
|
||||
error_page 500 502 503 504 /50x.html; |
error_page 500 502 503 504 /50x.html; |
||||
|
|
||||
location = /50x.html { |
location = /50x.html { |
||||
root /usr/share/nginx/html; |
root /usr/share/nginx/html; |
||||
} |
|
||||
} |
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue