# nginx : /usr/local/Cellar/nginx/nginx-1.17.8/objs/nginx # nginx.conf : /usr/local/nginx/conf/nginx.conf #user nobody; worker_processes auto; # 自动根据 CPU 核心数设置 events { worker_connections 1024; multi_accept on; # 提高并发连接效率 } #设定http服务器,利用它的反向代理功能提供负载均衡支持 http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; include mime.types; default_type application/octet-stream; # 全局性能优化 sendfile on; tcp_nopush on; tcp_nodelay on; # 动态内容传输优化 keepalive_timeout 65s; keepalive_requests 100; # 单连接最大请求数 # 默认启用 gzip gzip on; gzip_types text/plain text/css application/javascript application/json text/xml; gzip_min_length 1000; gzip_vary on; # 添加 Vary: Accept-Encoding 头 map $http_upgrade $connection_upgrade { default upgrade; '' close; } map $http_host $this_host { "" $host; default $http_host; } map $http_x_forwarded_proto $the_scheme { default $http_x_forwarded_proto; "" $scheme; } map $http_x_forwarded_host $the_host { default $http_x_forwarded_host; "" $this_host; } server { listen 8089; server_name localhost; location = / { proxy_pass http://jmalcloud:8088/articles; proxy_set_header Host $proxy_host; proxy_set_header X-real-ip $remote_addr; } location /api { proxy_pass http://jmalcloud:8088; proxy_set_header Host $proxy_host; proxy_set_header X-real-ip $remote_addr; } location /articles/articles { proxy_pass http://jmalcloud:8088/articles; proxy_set_header Host $proxy_host; proxy_set_header X-real-ip $remote_addr; } location /articles { proxy_pass http://jmalcloud:8088/articles; proxy_set_header Host $proxy_host; proxy_set_header X-real-ip $remote_addr; } location / { proxy_pass http://jmalcloud:8088/articles/; proxy_set_header Host $proxy_host; proxy_set_header X-real-ip $remote_addr; } } ###jmal-cloud-vie vue.js 前端配置 server { listen 80; server_name localhost; root /var/www/public; client_max_body_size 1024m; client_body_buffer_size 512k; location / { try_files $uri $uri/ /index.html; index index.html index.htm; } location = /blog { proxy_pass http://jmalcloud:8088/articles; proxy_set_header Host $proxy_host; proxy_set_header X-real-ip $remote_addr; } location = /blog/ { proxy_pass http://jmalcloud:8088/articles; proxy_set_header Host $proxy_host; proxy_set_header X-real-ip $remote_addr; } location /blog/api/ { proxy_pass http://jmalcloud:8088/; proxy_set_header Host $proxy_host; proxy_set_header X-real-ip $remote_addr; } location /blog/articles { proxy_pass http://jmalcloud:8088/articles/; proxy_set_header Host $proxy_host; proxy_set_header X-real-ip $remote_addr; } location /blog/ { proxy_pass http://jmalcloud:8088/articles/; proxy_set_header Host $proxy_host; proxy_set_header X-real-ip $remote_addr; } location /api/ { proxy_pass http://jmalcloud:8088/; proxy_http_version 1.1; proxy_set_header X-real-ip $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header X-Forwarded-Host $the_host/file; proxy_set_header X-Forwarded-Proto $the_scheme; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header Server-Protocol $server_protocol; proxy_set_header Server-Name $server_name; proxy_set_header Server-Addr $server_addr; proxy_set_header Server-Port $server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; sendfile on; tcp_nopush on; send_timeout 600s; # 延长超时 keepalive_timeout 600s; # 延长保持连接时间 output_buffers 1 512k; # 增大输出缓冲区 gzip off; # 禁用压缩,避免大文件开销 } location /webDAV/ { proxy_pass http://jmalcloud:8088/webDAV/; proxy_http_version 1.1; proxy_set_header X-real-ip $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header X-Forwarded-Host $the_host/file; proxy_set_header X-Forwarded-Proto $the_scheme; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header Server-Protocol $server_protocol; proxy_set_header Server-Name $server_name; proxy_set_header Server-Addr $server_addr; proxy_set_header Server-Port $server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; sendfile on; tcp_nopush on; send_timeout 600s; # 延长超时 keepalive_timeout 600s; # 延长保持连接时间 output_buffers 1 512k; # 增大输出缓冲区 gzip off; # 禁用压缩,避免大文件开销 } location /file/ { proxy_pass http://jmalcloud:8088/file/; proxy_http_version 1.1; proxy_set_header X-real-ip $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header X-Forwarded-Host $the_host/file; proxy_set_header X-Forwarded-Proto $the_scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header Server-Protocol $server_protocol; proxy_set_header Server-Name $server_name; proxy_set_header Server-Addr $server_addr; proxy_set_header Server-Port $server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; sendfile on; tcp_nopush on; send_timeout 600s; # 延长超时 keepalive_timeout 600s; # 延长保持连接时间 output_buffers 1 512k; # 增大输出缓冲区 gzip off; # 禁用压缩,避免大文件开销 } location /mq { proxy_pass http://jmalcloud:8088/mq/; #websocket额外配置开始 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_connect_timeout 60s;#l连接超时时间,不能设置太长会浪费连接资源 proxy_read_timeout 500s;#读超时时间 proxy_send_timeout 500s;#写超时时间 #websocket额外配置结束 } location /office { proxy_pass http://office/; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header X-Forwarded-Host $the_host/office; proxy_set_header X-Forwarded-Proto $the_scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header Server-Protocol $server_protocol; proxy_set_header Server-Name $server_name; proxy_set_header Server-Addr $server_addr; proxy_set_header Server-Port $server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } location /drawio/webapp/ { proxy_pass http://localhost:8080/; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header X-Forwarded-Host $the_host//drawio/webapp; proxy_set_header X-Forwarded-Proto $the_scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header Server-Protocol $server_protocol; proxy_set_header Server-Name $server_name; proxy_set_header Server-Addr $server_addr; proxy_set_header Server-Port $server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } location /pdf.js/ { proxy_pass http://localhost:8081/; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header X-Forwarded-Host $the_host//pdf.js; proxy_set_header X-Forwarded-Proto $the_scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header Server-Protocol $server_protocol; proxy_set_header Server-Name $server_name; proxy_set_header Server-Addr $server_addr; proxy_set_header Server-Port $server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } location /excalidraw/app/ { proxy_pass http://localhost:8082/excalidraw/app/; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header X-Forwarded-Host $the_host//excalidraw/app; proxy_set_header X-Forwarded-Proto $the_scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header Server-Protocol $server_protocol; proxy_set_header Server-Name $server_name; proxy_set_header Server-Addr $server_addr; proxy_set_header Server-Port $server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } } include servers/*; }