1、因为在配置了阿里云的负载均衡(SLB),将/fat转发到测试环境,以此用同一个域名来区分生产环境与测试环境,所以需要在测试环境中重写路由来去除路由中的/fat
2、修改nginx对应域名的配置文件
fastcgi_param参考:FastCGI中fastcgi_param 详细说明 - 风与叶子 - 博客园
server {
listen 80;
server_name xxx.com;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
charset utf-8;
if ($request_uri ~ /fat/(.*)$) {
set $new_request_uri /$1;
set $new_query_string $query_string;
set $new_request_method $request_method;
}
root /xxx/xxx/xxx; # 项目目录
index index.php;
# error_page 404 /index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ \.php$ {
fastcgi_pass docker_container:9000; # 对应项目的docker容器,这里主要是Nginx和PHP-FPM的进程间通信
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $new_request_uri;
fastcgi_param QUERY_STRING $new_query_string;
fastcgi_param REQUEST_METHOD $new_request_method;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
}