Last active
May 17, 2018 09:16
-
-
Save teror4uks/2d0ab7db350d9d6e0bead55a4c030c43 to your computer and use it in GitHub Desktop.
Docker Nginx configuration for dev enviroment with Django app
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
docker run --name rezerv-nginx \ | |
-v /path/to/nginx/config/nginx.conf:/etc/nginx/conf.d/app.conf \ | |
-v /path/to/django/project/folder/:/var/www/html/ \ | |
-v /path/to/uwsgi/socks/folder/:/var/run/ \ | |
-v /path/to/log/folder/:/var/log/nginx/ -d -p 8080:8080 nginx:latest | |
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 <can put docker ip>:8080; | |
server_name <docker container ip>; | |
client_max_body_size 10m; | |
client_body_timeout 1460; | |
send_timeout 1460; | |
keepalive_timeout 1300; | |
uwsgi_ignore_client_abort on; | |
gzip on; | |
gzip_disable "(msie6|Prerender)"; | |
gzip_types text/plain text/css application/json application/x-javascript | |
text/xml application/xml application/xml+rss | |
text/javascript application/javascript image/svg+xml; | |
gzip_comp_level 5; | |
access_log /var/log/nginx/app_nginx_access.log; | |
error_log /var/log/nginx/app_nginx_error.log; | |
root /var/www/html; | |
location /favicon.png { | |
proxy_pass http://<cdn domain or prod where live statics>/favicon.png; | |
} | |
location /robots.txt { | |
proxy_pass http://<cdn domain or prod where live statics>/robots.txt; | |
} | |
location /sitemap.xml { | |
proxy_pass http://<cdn domain or prod where live statics>/sitemap.xml; | |
} | |
location /static/ { | |
proxy_pass http://<cdn domain or prod where live statics>$request_uri; | |
} | |
# Angular templates | |
location /templates/ { | |
proxy_pass http://<cdn domain or prod where live statics>/templates; | |
} | |
location /media/ { | |
proxy_pass http://<cdn domain or prod where live statics>$request_uri; | |
} | |
location / { | |
uwsgi_pass unix:///var/run/uwsgi.sock; | |
include uwsgi_params; | |
uwsgi_param Host $host; | |
uwsgi_param X-Real-IP $remote_addr; | |
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for; | |
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto; | |
uwsgi_send_timeout 3000; | |
uwsgi_read_timeout 3000; | |
uwsgi_buffers 8 128k; | |
uwsgi_ignore_client_abort on; | |
} | |
} |
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
source <YOUR VIRTUAL ENV ENVIRONMENT>/bin/activate | |
uwsgi /path/to/config/file/uwsgi.ini --chmod-socket=666 |
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
[uwsgi] | |
home=/path/to/env/root/folder/ | |
chdir=/path/to/django/project/ | |
master=True | |
disable-logging=True | |
vacuum=True | |
max-requests=5000 | |
socket=/path/to/uwsgi/socket/uwsgi.sock | |
workers=2 | |
buffer-size=32768 | |
pythonpath=/path/to/env/root/folder/ | |
env=DJANGO_SETTINGS_MODULE=settings | |
module=wsgi:application | |
touch-reload=/path/to/touch/reload/txt/file/reload.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment