nginx server to serve static content, fixes #5

This commit is contained in:
Massaki Archambault 2018-05-08 10:34:12 -04:00
parent 2d1293320d
commit d19f0ebc42
2 changed files with 40 additions and 1 deletions

View File

@ -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:

23
nginx.conf Normal file
View File

@ -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;
}
}