我只是设置了当访问者使用以下代码访问我的网站时从http到https重定向。
server {
listen 80;
ssl off;
server_name seoartgallery.com www.seoartgallery.com ja.seoartgallery.com www.ja.seoartgallery.com;
root /var/www/seoart;
location =/example.txt {
# do stuff
}
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name seoartgallery.com ja.seoartgallery.com www.seoartgallery.com www.ja.seoartgallery.com;
root /var/www/seoart;
index index.php;
ssl_certificate /etc/letsencrypt/live/seoartgallery.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/seoartgallery.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/seoartgallery.com/chain.pem;
ssl_dhparam /etc/letsencrypt/live/seoartgallery.com/seoartgallery.com.dhparam;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4;
# Enable HSTS. This forces SSL on clients that respect it, most
# modern browsers. The includeSubDomains flag is optional.
add_header Strict-Transport-Security "max-age=31536000";
# Set caches, protocols, and accepted ciphers. This config will
# merit an A+ SSL Labs score.
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
error_log /var/log/nginx/seoart.error.log warn;
location / {
try_files $uri $uri/ /index.php?$args;
}
# Allow Lets Encrypt Domain Validation Program
location ^~ /.well-known/acme-challenge/ {
allow all;
}
# Add a slash at the end of request */wp-admin
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Deny files starting with a . (dot)
location ~ /\. {
deny all;
}
location ~ /.well-known {
allow all;
}
# Add Rocket-Nginx configuration (of course !!)
include common/yoast.conf;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
但我想只设置1个文件没有重定向到https。 例子)http://example.com/example.txt
但我不知道我是怎么做的
请让我知道如何解决这个问题
谢谢
答案 0 :(得分:1)
以下内容应该有效:
server {
listen 80;
server_name example.com;
location = /example.txt {
# do stuff
}
location / {
return 301 https://$host$request_uri;
}
}