1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| upstream apicluster{ server 10.10.0.110:30008; server 10.10.0.111:30008; server 10.10.0.185:30008; server 10.10.0.186:30008; }
server { listen 443; # listen [::]:443 http2; server_name example.com; root /var/www/example.com/public;
# SSL # ssl_certificate /etc/nginx/ssl/example.com.crt; # ssl_certificate_key /etc/nginx/ssl/example.com.key;
# security include /etc/nginx/nginxconfig.io/security.conf;
# logging access_log /var/log/nginx/example.com.access.log; error_log /var/log/nginx/example.com.error.log warn; # index.html fallback location / { # root /var/www/example.com/public; try_files $uri $uri/ @router; index index.html index.htm; error_page 405 =200 http://$host$request_uri; }
#代理后端接口 location /api/ { proxy_pass http://apicluster; #转发请求的地址 rewrite ^/api/(.*)$ /$1 break; include /etc/nginx/nginxconfig.io/proxy.conf; } # WebSocket location /hubs/ { proxy_pass http://apicluster; #转发请求的地址 include /etc/nginx/nginxconfig.io/proxy.conf; } location @router { rewrite ^.*$ /index.html last; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }
# additional config include /etc/nginx/nginxconfig.io/general.conf; }
# HTTP redirect server { listen 80; listen [::]:80; server_name example.com; return 301 https://example.com$request_uri; }
|