I'm trying to access multiple docker containers running on a server via a nginx as a reverse proxy.
Each container is a self contained CMS. Some are wordpress, some are drupal, etc etc.
The command I'm starting the containers with:
docker run -p 0.0.0.0:{$port}:80 -i -t loader-docker The big difference here is I want to access each container via a path rather than a subdomain.
For example: http://example.com/docker-1 http://example.com/docker-2
I can do this easily enough with the following config
server { listen 80; server_name example.com; location / {} location /docker-1/ { proxy_set_header Host $host; 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 $scheme; proxy_pass docker.server:8001; } location /docker-2/ { proxy_set_header Host $host; 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 $scheme; proxy_pass docker.server:8002; } } When I go to http://example.com/docker-1 I'm hitting the docker container running on port 8001 on an internal server. Likewise when I go to http://example.com/docker-2
The issue is as each of these containers are running CMS's none of the paths are now correct and all resources fail to load.
The path the CMS is looking for is actually docker.server (the internal server) but it's getting http://example.com/
Is it possible to solve this in nginx, or do I have to write custom .htaccess rules for each of the containers? If so how would I go about that?
I should note that each container is running Apache as its web server.