I want to run severel services/pages behind nginx. Each service shall be available through a subdirectory instead of a subdomain.
I'am using jwilder/nginx-proxy as proxy container:
nginx_proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- 80:80
volumes:
- /var/run/docker.sock:/tmp/docker.sock
And the owncloud container:
web:
image: owncloud:8.1
container_name: my_owncloud
environment:
- VIRTUAL_HOST=www.example.com
ports:
- 8081:80
The modified nginx config:
# 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/;
}
}
The problem is that owncloud tries to load styles, images, etc. from / instead of /cloud. Owncloud itself is working and is reachable by domain.org:8081. Do I have to add some rewrite, proxy_redirect or other stuff?