Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # normally you leave this at the default of 1024
- events {
- worker_connections 1024;
- }
- http {
- client_max_body_size 512M;
- upstream django {
- server web:8000;
- }
- sendfile on;
- send_timeout 300s;
- server {
- client_max_body_size 512M;
- listen 80 default_server;
- server_name my.site.ru;
- # ------------------------------------------------------------ STATIC FILES ---
- location /static {
- location /static/admin { alias /app/static-files/admin; }
- location /static/rest_framework { alias /app/static-files/rest_framework; }
- location /static/debug_toolbar { alias /app/static-files/debug_toolbar; }
- location /static/fonts { alias /webapp/build/static/fonts; }
- location /static/icons { alias /webapp/build/static/icons; }
- location /static/images { alias /webapp/build/static/images; }
- location /static/img { alias /webapp/build/static/img; }
- # new path from webpack
- location /static/scripts { alias /webapp/build/static/scripts; }
- location /static/styles { alias /webapp/build/static/styles; }
- # http://stackoverflow.com/q/19213510/1346257
- include /etc/nginx/mime.types;
- autoindex off;
- }
- location /assets {
- alias /webapp/build/assets;
- include /etc/nginx/mime.types;
- autoindex off;
- }
- # ----------------------------------------------------------- COMMON CONFIG ---
- location = /robots.txt { return 200 "User-agent: *\nAllow: /"; }
- location = /favicon.ico {
- add_header 'Content-Type' image/vnd.microsoft.icon;
- alias /webapp/build/favicon.ico;
- access_log off;
- log_not_found off;
- }
- #Prevent serving of sysfiles / vim backup files
- location ~ /\. { access_log off; log_not_found off; deny all; }
- location ~ ~$ { access_log off; log_not_found off; deny all; }
- # -------------------------------------------------------------- USER FILES ---
- location /file/uploads/public/ {
- add_header 'Access-Control-Allow-Origin' * always;
- alias /app/uploads/public/;
- include /etc/nginx/mime.types;
- autoindex off;
- }
- # ------------------------------------------------------------------- ICONS ---
- location /file/uploads/icon/ {
- add_header 'Access-Control-Allow-Origin' * always;
- alias /app/uploads/icon/;
- include /etc/nginx/mime.types;
- autoindex off;
- }
- # ------------------------------------------------------------ SYSTEM FILES ---
- location /file/uploads/sys/ {
- add_header 'Access-Control-Allow-Origin' * always;
- alias /app/uploads/sys/;
- include /etc/nginx/mime.types;
- autoindex off;
- }
- # ------------------------------------------------ REDIRECT TO /index.html ---
- # redirect all requests to /index.html
- location / {
- client_max_body_size 512M;
- rewrite ^ /index.html;
- }
- location = /index.html {
- alias /webapp/build/index.html;
- }
- location = /manifest.json {
- alias /webapp/build/manifest.json;
- }
- # --------------------------------- MAIN ENTRYPOINT: /api /admin /rest-auth ---
- location /api/ {
- client_max_body_size 512M;
- add_header 'Access-Control-Allow-Origin' * always;
- add_header 'Access-Control-Allow-Credentials' 'true' always;
- add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,Cache-Control,X-Mx-ReqToken,Keep-Alive,If-Modified-Since,X-CSRF-Token,x-csrftoken,X-CSRFToken,X-$
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
- if ($request_method = 'OPTIONS') {
- add_header 'Access-Control-Allow-Origin' * always;
- add_header 'Access-Control-Allow-Credentials' 'true' always;
- add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,Cache-Control,X-Mx-ReqToken,Keep-Alive,If-Modified-Since,X-CSRF-Token,x-csrftoken,X-CSRFToke$
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
- add_header 'Content-Length' 0 always;
- add_header 'Content-Type' application/json always;
- expires 1d;
- access_log off;
- return 204;
- }
- uwsgi_pass django;
- include uwsgi_params;
- }
- location /rest-auth/ {
- add_header 'Access-Control-Allow-Origin' * always;
- add_header 'Access-Control-Allow-Credentials' 'true' always;
- add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,Cache-Control,X-Mx-ReqToken,Keep-Alive,If-Modified-Since,X-CSRF-Token,x-csrftoken,X-CSRFToken,X-$
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
- uwsgi_pass django;
- include uwsgi_params;
- }
- location /admin/ {
- uwsgi_pass django;
- include uwsgi_params;
- }
- location /__debug__/ {
- uwsgi_pass django;
- include uwsgi_params;
- }
- error_page 405 =200 ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement