내 nginx 설정 파일은 다음과 같습니다.
server {
listen 80;
listen 443 ssl;
server_name XXX.com;
error_log /log/nginx/xxx.com_error.log;
access_log /log/nginx/xxx.com_access.log main;
root /data/www/;
index index.php index.html index.htm;
location ~ \.php$ {
add_header X-Frame-Options SAMEORIGIN;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
다음을 만족시키기 위해 nginx를 설정해야합니다 :
URL이 경우 1, 하지 않는 접두사가 "/api/mobile/index.php",and 요청의 포트는 80 URL이 경우, HTTPS 2로 리디렉션 이 계속 /api/mobile/index.php",just 접두사를"
구성 파일에 내용을 추가합니다.
location ~ ^(?!/api/mobile/index\.php).*$ {
if ($server_port = "80") {
return 301 https://$server_name$request_uri;
}
rewrite /* $server_name$reqeust_uri last;
}
이제 구성 파일 내용은 다음과 같습니다.
server {
listen 80;
listen 443 ssl;
server_name XXX.com;
error_log /log/nginx/xxx.com_error.log;
access_log /log/nginx/xxx.com_access.log main;
root /data/www/;
index index.php index.html index.htm;
location ~ ^(?!/api/mobile/index\.php).*$ {
if ($server_port = "80") {
return 301 https://$server_name$request_uri;
}
rewrite /* $server_name$reqeust_uri last;
}
location ~ \.php$ {
add_header X-Frame-Options SAMEORIGIN;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
요청이 첫 번째 위치와 일치하고 다른 위치와 일치하지 않습니다.
이는 이러한 요청이 PHP cgi를 통과 할 수 없음을 의미합니다.
문제를 해결하는 방법을 아는 사람이 있습니까?