worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; client_max_body_size 1024m; map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name localhost; location / { root /home/vctgo/projects/vctgo-ui; try_files $uri $uri/ /index.html; index index.html index.htm; } # 平台端前端文件 location /platform { root /home/vctgo/projects; try_files $uri $uri/ /platform/index.html; index index.html index.htm; } # 幼儿园端前端文件 location /kindergarten { root /home/vctgo/projects; try_files $uri $uri/ /kindergarten/index.html; index index.html index.htm; } location /prod-api/ { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://vctgo-gateway:38080/; } # 第一个.*服务名称与网关配置一致,第二个.*是具体的业务 location ~ /prod-api/(.*)/websocket/(.*) { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_pass http://vctgo-gateway:38080/$1/websocket/$2?$query_string; } # 避免actuator暴露 if ($request_uri ~ "/actuator") { return 403; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }