From d19f0ebc429585c07ecc4a5f127e3a9ea38cec0f Mon Sep 17 00:00:00 2001 From: Massaki Archambault Date: Tue, 8 May 2018 10:34:12 -0400 Subject: [PATCH] nginx server to serve static content, fixes #5 --- docker-compose.yml | 18 +++++++++++++++++- nginx.conf | 23 +++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index 2422aa8..4be7650 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,12 +5,12 @@ services: container_name: postal command: run ports: - - 127.0.0.1:80:5000 - 127.0.0.1:25:25 depends_on: - "mysql" - "rabbitmq" volumes: + - static_assets:/opt/postal/public - ./data/postal/assets:/opt/postal/public/assets - ./data/postal/config:/opt/postal/config environment: @@ -34,3 +34,19 @@ services: - RABBITMQ_DEFAULT_USER=postal - RABBITMQ_DEFAULT_PASS=changeme - RABBITMQ_DEFAULT_VHOST=/postal + nginx: + image: nginx + restart: always + ports: + - 127.0.0.1:80:80 + links: + - postal + depends_on: + - postal + volumes: + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro + - static_assets:/opt/postal/public:ro + - ./data/postal/assets:/opt/postal/public/assets:ro +volumes: + static_assets: + diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..6e6e638 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,23 @@ +server { + listen 80; + + root /opt/postal/public; + + location / { + client_max_body_size 50M; + try_files $uri $uri/index.html $uri.html @puma; + } + + location /assets { + add_header Cache-Control max-age=3600; + } + + location @puma { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://postal:5000; + } +} +