我今天一直试图为我网站上的两个目录激活 SSL,但到目前为止还没有成功。我尝试了 serverfault 上看到的几种修复方法,但都不起作用。网站的布局如下:
- examplesite.com 是一个标准的 WordPress 网站
- examplesite.com/shop 是一个 MarketPress 商店,是 WordPress 的一个插件,作为 maine examplesite.com 安装的一部分运行
- examplesite.com/classifieds 是一个单独的 WordPress 安装
我需要为 examplesite.com/shop 和 examplesite.com/classifieds 打开 SSL,但到目前为止还无法正确地调整我的配置。
如果有人有更好的方法来组织这个或修复下面的配置,我将不胜感激。
server {
server_name xamplesite.com www.examplesite.com;
listen 80;
server_tokens off;
access_log /home/nginx/domains/examplesite.comv/log/access.log combined buffer=32k;
error_log /home/nginx/domains/examplesite.com/log/error.log;
root /home/nginx/domains/examplesite.com/public;
location /shop {
rewrite ^ https://$host$request_uri permanent;
}
location /classifieds {
rewrite ^ https://$host$request_uri permanent;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
include /usr/local/nginx/conf/staticfiles.conf;
include /usr/local/nginx/conf/php.conf;
include /usr/local/nginx/conf/drop.conf;
include /usr/local/nginx/conf/block.conf;
include /usr/local/nginx/conf/wordpress/restrictions.conf;
include /usr/local/nginx/conf/wordpress/wordpress.conf;
}
server {
listen 443;
server_name 127.0.0.1;
access_log /home/nginx/domains/examplesite.com/log/access.log combined buffer=32k;
error_log /home/nginx/domains/examplesite.com/log/error.log;
root /home/nginx/domains/examplesite.com/public;
ssl on;
ssl_certificate /etc/ssl/certs/example.crt;
ssl_certificate_key /etc/ssl/private/example.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
location /shop {
try_files $uri $uri/ /index.php?$args;
}
location /classifieds {
try_files $uri $uri/ /index.php?$args;
}
location / {
rewrite ^ http://$host$request_uri permanent;
}
}
答案1
尝试更改listen 443;
为listen 443 ssl;
。