我在同一台服务器 (CentOS6) 上安装了 Plone4 和 Nginx。Nginx 运行速度很快,但 Plone 站点上的所有链接都收到了 target="_blank" 属性。使用 Nginx 时,所有链接都在新窗口中打开。我使用 Zope 网络服务器或通过 apache 打开同一个 Plone 站点,问题消失了。我尝试了不同的配置,但无法获得正确的链接。我该如何解决这个问题?
我当前的 Nginx 配置是:
add_header X-Frame-Options "SAMEORIGIN";
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
#add_header Content-Security-Policy "default-src 'self'; img-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'";
add_header Content-Security-Policy-Report-Only "default-src 'self'; img-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'";
upstream plone {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name mywebsite.com;
rewrite ^/(.*) http://www.mywebsite.com/$1 permanent;
}
server {
listen 80;
server_name www.mywebsite.com;
access_log /var/log/nginx/mywebsite.com.access.log;
error_log /var/log/nginx/mywebsite.com.error.log;
location / {
#proxy_pass http://plone/VirtualHostBase/http/mywebsite.com:80/mywebsite/VirtualHostRoot/;
rewrite ^/(.*)$ /VirtualHostBase/http/mywebsite.com:80/mywebsite/VirtualHostRoot/$1 break;
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
答案1
它可能与您的 URL 有关。如果启用,Plone 将在新窗口中打开外部 URL。
检查你的重写规则:
rewrite ^/(.*)$ /VirtualHostBase/http/mywebsite.com:80/mywebsite/VirtualHostRoot/$1 break;
我认为应该是:
rewrite ^/(.*)$ /VirtualHostBase/http/www.mywebsite.com:80/mywebsite/VirtualHostRoot/$1 break;