Ok guys here is the problem: i have my webserver serving a website, a cms and mobile app api using a subdirectory approach like this
- localhost -> site
- localhost/cms
- localhost/api
everything is built using docker compose
services:
server:
build: ./docker/nginx
links:
- fpm
ports:
- 80:80
- 443:443
fpm:
build: ./docker/php
links:
- database
- smtp
database:
build: ./docker/mariadb
volumes:
- dbdata:/var/lib/mysql
volumes:
dbdata:
What i'd like to do is to add 2 new containers: one for wordpress and one for the wordpress db in order to proxy pass every request to mydomain.dom/blog to the wordpress container. I was able to pass the request using a nginx config like below but unfortunately i'm fighting with the container which keeps redirecting everything to localhost instead of localhost/blog, i think i'm missing some config in wordpress.
location /blog/ {
proxy_http_version 1.1;
proxy_buffering off;
proxy_read_timeout 90;
proxy_connect_timeout 90;
proxy_redirect off;
proxy_pass http://blog:80; # the wordpress container name
proxy_set_header Host $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;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
}
# Cms stuff
location /cms/ {
try_files $uri $uri/ /staff/index.php?$args;
include _php.conf; # php-fpm setup
}
# Site stuff
location / {
try_files $uri $uri/ /index.php?$args;
include _php.conf; # php-fpm setup
}