【问题标题】:Owncloud 8 with Docker behind nginx available through subdirectory可通过子目录在 Nginx 后面使用 Docker 的 Owncloud 8
【发布时间】:2016-10-08 17:14:13
【问题描述】:

我想在 nginx 后面运行严格的服务/页面。每个服务都应通过子目录而不是子域提供。

我正在使用 jwilder/nginx-proxy 作为代理容器:

nginx_proxy:
  image: jwilder/nginx-proxy
  container_name: nginx-proxy
  ports:
    - 80:80
  volumes:
    - /var/run/docker.sock:/tmp/docker.sock

还有 owncloud 容器:

web:
  image: owncloud:8.1
  container_name: my_owncloud
  environment:
    - VIRTUAL_HOST=www.example.com
  ports:
    - 8081:80

修改后的nginx配置:

# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
  default $http_x_forwarded_proto;
  ''      $scheme;
}
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
  default upgrade;
  '' close;
}
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
log_format vhost '$host $remote_addr - $remote_user [$time_local] '
                 '"$request" $status $body_bytes_sent '
                 '"$http_referer" "$http_user_agent"';
access_log off;

# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;

upstream cloud {
        server 172.17.0.3:80:
}
server {
        server_name domain.org www.domain.org;
        listen 80;
        access_log /var/log/nginx/access.log vhost;

        index index.html index.htm index.php;
        root /var/www/main;

        location /cloud/ {
                proxy_pass http://cloud/;
        }

        location / {
                proxy_pass http://www.some-domain.com/;
        }

        location /sub/ {
                alias /var/www/sub/;
        }

}

问题是owncloud试图从/而不是/cloud加载样式、图像等。 Owncloud 本身正在运行,并且可以通过 domain.org:8081 访问。我是否必须添加一些 rewrite、proxy_redirect 或其他东西?

【问题讨论】:

  • 你最后搞定了吗?
  • 不,抱歉。我切换回子域。

标签: nginx docker proxypass owncloud


【解决方案1】:

您可以使用“覆盖webroot”as described in the manual。编辑您自己的云的 'config/config.php' 并包括:

<?php
$CONFIG = array (
    ...
    'overwritewebroot' => '/cloud',
    ...
);

然后,owncloud 会将“/cloud/”视为任何内部 URL(例如,图像、样式等)的基础。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-05
    • 1970-01-01
    • 2014-02-28
    • 2021-08-23
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 2015-11-20
    相关资源
    最近更新 更多