Docker: Version 18.02.0-ce-rc2-mac51 (22446)
Docker Compose: 1.19.0-rc2
OS: macOS Sierra 10.12.6
I’m using Nginx as a sidecar container to proxy an ExpressJS application, both Nginx and Express works but I cannot proxy to ExpressJS for some reason.
If I curl http://localhost:8080 it always gives me the default Nginx page instead of ExpressJS app home page.
Please advise!
// docker-compose.yml
---
version: '2.3'
services:
web:
image: nginx:1.13.8
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "8080:80"
app:
build: ./app/
// Nginx config
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
##
# Gzip Settings
##
gzip on;
gzip_proxied any;
gzip_types text/plain application/json;
gzip_min_length 1000;
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/app.log;
location / {
proxy_pass http://app:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}