- download these two files to the same directory
- docker-compose up
- http://localhost should show you "it works" which is apache being reverse-proxied through nginx
- docker sets up DNS for
web
based on compose service name so the nginx front-end can find http://web - proxy is set to listen on public port 80 on host so it'll receive incoming traffic, then push to httpd
-
-
Save pankajred/c265830e7ca5e3a7d5ee5971c956b706 to your computer and use it in GitHub Desktop.
Simple Apache + Nginx Reverse Proxy Example in Docker Compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
proxy: | |
image: nginx:1.11 # this will use the latest version of 1.11.x | |
ports: | |
- '80:80' # expose 80 on host and sent to 80 in container | |
volumes: | |
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro | |
web: | |
image: httpd # this will use httpd:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
location / { | |
proxy_pass http://web; | |
proxy_redirect off; | |
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-Host $server_name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment