server { listen 80; index index.php index.html; server_name bz.crmeb.com; client_max_body_size 100M; root /var/www/public; # 端口映射场景(宿主机 8011 -> 容器 80):目录补斜杠 301 使用相对 Location, # 避免跳转后丢失宿主机映射端口 absolute_redirect off; location / { # try_files $uri /index.php$is_args$args; if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; error_log off; access_log /dev/null; } location ~ .*\.(js|css)?$ { expires 12h; error_log off; access_log /dev/null; } # 统一长连接网关:所有 WebSocket 业务共用一个入口(后台通知、客服聊天及后续新业务) # 客户端通过 ?service= 参数区分目标业务,服务器只需配置此一处反代即可 location /ws { proxy_pass http://crmeb_workerman:40001; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-real-ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_read_timeout 3600s; proxy_send_timeout 3600s; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass phpfpm:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } }