我的 Nginx https 配置遇到问题。每当我访问带有 GET 参数的 URL(例如 https://example.com?id=32 或 http://example.com?page=1)时,服务器都会返回 HTTP 403 Forbidden 错误。但是,该页面无需参数即可正常工作,例如 https://example.com。
Nginx php 8.3 拉拉维尔 11
这是 nginx 代码
server {
listen 80;
server_name dummy.example.com;
# Redirect all HTTP traffic to HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name dummy.example.com;
merge_slashes off;
# SSL Configuration
ssl_certificate /path/to/certificate/example.com.cer;
ssl_certificate_key /path/to/certificate/example.com.key;
ssl_trusted_certificate /path/to/certificate/example.com_chain.cer;
# SSL Optimization
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:10m;
# Laravel Backend
root /var/www/html/example/backend/public;
index index.php index.html;
# Laravel route handling
location / {
try_files $uri /index.php?$query_string;
try_files $uri $uri/ /index.php$is_args$args;
}
# PHP FastCGI Configuration for Laravel
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# Deny Access to Hidden and Sensitive Files
# location ~ /\.(?!well-known).* {
# deny all;
# }
# Logging
error_log /var/log/nginx/dummy_error.log;
access_log /var/log/nginx/dummy_access.log;
}