tamasszoke/mern-seed

set up with Nginx

okrymus opened this issue · 2 comments

I try to set up with Nginx but I always get 502 Bad Gateway. Do you have any suggest?

Here is docker-compose.production.yml

services:
  nginx:
    image: nginx:1.16 # this will use the latest version of 1.13.x
    ports:
      - "80:80" # expose 80 on host and sent to 80 in container
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - app
  redis:
    image: "redis:alpine"
    ports:
      - "6379:6379"
    hostname: redis
  app:
    container_name: app
    build:
      context: ./
    restart: always
    ports:
      - "8080:8080"
    environment:
      NODE_ENV: production
    depends_on:
      - redis

And this is Nginx config

server {
    listen 80;
    server_name example.org
    location / {
        proxy_pass http://127.0.0.1:8080;
        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;
        proxy_redirect off;
     }
}

Thank you!!

I'm planning to add a couple updates, including Nginx in a week or two.
I'll report back here if I run into a similar issue.

Thank you! however, I solved the problem.