Я установил ssl на свой сервер, и он работает нормально, но проблема в том, что если какой-либо пользователь попытается получить доступ к сайту без https, он переадресует на https без строки запроса.ngnix https redirect with querystring
http://example.com?av=23423423 до https://example.com только он не перенаправляется с помощью строки запроса. Я пытаюсь добавить ниже код, но он не работает.
if ($http_x_forwarded_proto = "http") {
return 301 https://$server_name$request_uri;
}
Мой конфиг ниже, любой может помочь в этом?
upstream mysitecombackend { сервер unix: /var/run/php-fcgi-mysitecom.sock; }
upstream exmplecombackend {
server unix:/var/run/php-fcgi-exmplecom.sock;
}
server {
listen 1.2.4.3:443 ssl;
server_name exmple.com *.exmple.com;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;
ssl_prefer_server_ciphers on;
ssl_certificate /etc/ssl/www.exmple.com.cabundle;
ssl_certificate_key /etc/ssl/exmple.key;
location/{
proxy_pass http://127.0.0.1:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 443;
# proxy_set_header Host $host$request_uri;
proxy_set_header Host $host;
proxy_set_header Ssl-Offloaded "1";
}
#rewrite ^/(.*) https://exmple.com/$1 permanent;
}
server {
listen 80 default_server;
server_name exmple.com www.exmple.com;
# return 301 https://$host$request_uri;
root /var/www/vhosts/exmple.com/public;
location/{
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
location /. {
return 404;
}
location @handler {
rewrite//index.php;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
include "ssl_offloading.inc";
location ~ .php$ {
if (!-e $request_filename) { rewrite//index.php last; }
expires off;
fastcgi_pass exmplecombackend;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param MAGE_RUN_CODE default;
# fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;
}
}
Благодаря @Richard Смит, это работает для меня –