我有一个 Nginx 服务器,强制所有网站使用 HTTPS,但我只需要 HTTP 中的 URL。
这是网址:
https://site.meudominio.com.br/index.php?route=primeiro/segundo/terceiro/funcao
我希望它被强制停留在 HTTP 中,就像这样并保持:
http://site.meudominio.com.br/index.php?route=primeiro/segundo/terceiro/funcao
我的配置文件是:
server {
listen 80;
listen [::]:80;
server_name site.meudominio.com.br;
return 301 https://site.meudominio.com.br$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name site.meudominio.com.br;
ssl on;
ssl_certificate /etc/ssl/fullchain.pem;
ssl_certificate_key /etc/ssl/privkey.pem;
include snippets/ssl-params.conf;
root /var/www/meudominio.com.br/site;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri @meudominio;
}
location @meudominio {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}
答案1
问题出在你的 http部分return 301
。它告诉 Nginx 将通过 http 进入的所有人发送到 https URL。