Last active
April 16, 2020 11:22
-
-
Save sotnikov-link/6bd6746649ef22b4d48fb60c5f561204 to your computer and use it in GitHub Desktop.
NGINX Config for Next.js Static site + docker-compose.yml
This file contains hidden or 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: | |
nginx: | |
image: 'nginx:alpine' | |
ports: | |
- 80:80 | |
volumes: | |
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro | |
- ./out:/usr/share/nginx/html:ro |
This file contains hidden or 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; | |
server_name localhost; | |
root /usr/share/nginx/html; | |
index index.html; | |
error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
location / { | |
# try_files $uri $uri/ /index.html; | |
try_files $uri $uri.html $uri/ /index.html; | |
} | |
# Location of asset folder | |
location ~ ^/(_next)/ { | |
gzip_static on; | |
gzip_types text/plain text/xml text/css | |
text/comma-separated-values | |
text/javascript application/x-javascript | |
application/atom+xml; | |
expires max; | |
} | |
# Прокси для локального бэка | |
location ~ ^/(api)/ { | |
proxy_pass http://host.docker.internal:8000; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Real-IP $remote_addr; | |
} | |
# Для отладки в dev-режиме | |
# location ~ ^/ { | |
# proxy_pass http://host.docker.internal:3000; | |
# proxy_set_header Host $host; | |
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
# proxy_set_header X-Real-IP $remote_addr; | |
# } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment