Docker和卸载资产上的Nginx反向代理

时间:2017-01-31 19:36:19

标签: nginx docker reverse-proxy

我希望通过Docker提供我的博客(由Ghost提供支持),并通过网址cv.totem.io/blog访问。

问题是网址无法更正。 对于亲戚网址: <script src="/ghost/ghost.js?v=b0685c4e1f"></script> 对于绝对: <link rel="canonical" href="http://localhost:2368/">

对于绝对URL而言,这似乎是Docker容器的配置问题,而对于亲属来说,这是Nginx的问题。

这是我的Nginx配置:

server {
        listen 443;
        server_name cv.totem.io;
        rewrite ^(.*) http://$host$1 permanent;
}

upstream blog {
        server 127.0.0.1:7070;
        keepalive 8;
}

server {
        server_name www.cv.totem.io cv.totem.io;

        location / {
                root /var/www/totem/curriculum;
                index index.html index.htm;
        }

    location /blog {
                proxy_pass http://blog/;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
                proxy_set_header X-NginX-Proxy true;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_redirect off;
        }
}

docker container已通过此命令重新安装:

docker run --name some-ghost -p 7070:2368 -d ghost

1 个答案:

答案 0 :(得分:-1)

您必须在网址中加入/博客才能匹配“位置/博客”#39;在nginx中阻止。

更改网址如下:

<script src="/blog/ghost/ghost.js?v=b0685c4e1f">
<link rel="canonical" href="http://localhost:2368/blog">