nginx notes

Submitted by code_admin on Fri, 04/12/2019 - 18:40

Server block with python redirect and url rewrites

  1. server {
  2.     listen      80;
  3.     server_name localhost; ##ignored if there is only one server block
  4.     charset     utf-8;
  5.     client_max_body_size 75M;
  6.  
  7.     #location = /frontend/webfrontendConnectionData {
  8.     #    try_files $uri @yourapplication;
  9.     #}
  10.     location /public/web/frontend {
  11.         alias /frontend/;
  12.         autoindex off;
  13.     }
  14.     # try_files _ @xxx means don't look at any file go to xxx block
  15.    
  16.     #Turn around /public/api to /api/public because Python has to be one way and kong the other
  17.     location /public/api {
  18.         rewrite ^/public/api(.*)$ /api/public/api$1? break;
  19.         try_files _ @yourapplication;
  20.     }
  21.     location /authed/api {
  22.         rewrite ^/authed/api(.*)$ /api/authed/api$1? break;
  23.         try_files _ @yourapplication;
  24.     }
  25.     #This redirect didn't work. The location seems to select but:
  26.     #got an nginx 404 Dosen't work with or without trailing slash on alias
  27.     #location /public/web/apidocs/swaggerui/bower/swagger-ui/dist {
  28.     #    alias /usr/lib/python3.6/site-packages/baseapp_for_restapi_backend_with_swagger/static/;
  29.     #    autoindex off;
  30.     #}
  31.     location /public/web/apidocs {
  32.         rewrite ^/public/web(/apidocs.*)$ /$1? break;
  33.         try_files $1 @yourapplication;
  34.     }
  35.     #location / {
  36.     #    try_files _ @yourapplication;
  37.     #}
  38.     location @yourapplication {
  39.         include uwsgi_params;
  40.         uwsgi_pass unix:/app/uwsgi.sock;
  41.     }    
  42. }

Tags

RJM Article Type
Work Notes