【问题标题】:Allowing Wordpress to be hosted on a subfolder within an already existing site允许 Wordpress 托管在现有站点中的子文件夹上
【发布时间】:2015-07-17 16:54:10
【问题描述】:

我们有一个客户的请求,我们需要在我们的网站中托管一个 wordpress 网站。在内部,我的意思是该站点不能位于子域中,即https://blog.example.com,而是需要位于其自己的路由/子文件夹中,即https://www.example.com/blog。这是由于页面排名(显然页面排名如果放在子域中会受到惩罚)

问题是,我们的网站不是用 PHP 运行的(它是用 Scala 编写的,可以在 Jetty 上运行)。此外,我们的主站点是从一个由 Nginx 支持的 Docker 容器运行的。

理想情况下,我希望将 Wordpress 托管在其自己的单个服务器上(Docker 容器化与否,这不是一个大问题),并在我们主站点的 nginx 配置中,将其反向到特定 URL 的外部服务器(即https://www.example.com/blog 将指向运行 wordpress 的外部服务器的 IP/主机)

您将如何实现这一目标/可能吗?这是我们主服务器的当前nginx.conf

server {
    listen 80;
    listen [::]:80;
    listen       443 default_server ssl;
    server_name  www.example.com.au;

    ssl_certificate      /etc/nginx/cert.crt;
    ssl_certificate_key  /etc/nginx/cert.key;

    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  5m;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA256:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EDH+aRSA+AESGCM:EDH+aRSA+SHA256:EDH+aRSA:EECDH:!aNULL:!eNULL:!MEDIUM:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED";

    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";

    if ($scheme = http) {
        return 301 https://$server_name$request_uri;
    }

    location / {
         proxy_pass http://localhost:8080;
         proxy_redirect http://www.example.com.au /;
         proxy_set_header    Host            $host;
         proxy_set_header    X-Real-IP       $remote_addr;
         proxy_set_header    X-Forwarded-for $remote_addr;
         proxy_read_timeout 600s;
         port_in_redirect off;
    }
}

这是我们当前nginx.conf 的示例,如您所见,实际网站托管在localhost:8080 上,我们只是主站点的代理重定向。

【问题讨论】:

    标签: wordpress nginx docker


    【解决方案1】:

    假设wordpress服务托管在http://localhost:8081,那么你可以只proxy_pass/blog请求http://localhost:8081,你可以在你的nginxserver块中添加以下块:

        location ^~ /blog {
             proxy_pass http://localhost:8081;
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-04
      • 2012-10-03
      • 1970-01-01
      • 1970-01-01
      • 2018-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多