Monday 15 April 2013

python - How to properly setup nginx as a reverse proxy for gunicorn and flask using subdomains, for both SSL and non-SSL configurations? -


Can someone please post a nginx configuration file that shows how to properly bring the following URLs to Gonochorn:

  • Li>
  • Why are some NGNX configuration files included "upstream command"?
  • I am running 2 N + 1 gun activist, do I need too many NGNX workers? That means, I mean, should I serve nginx only to static files after the "worker_processes" command?
  • How to set buffering / caching?

      server {80 default_server deferred; 443 Default_Server Listen to suspended SSL; Listen [::]: 80 ipv6only = deferred on default_server; Listen [:]: 443 ipv6only = deferred SSL on default_server; Server_name example.com www.example.com test.example.com; Root / path / copy / static / files # SSL stuff location / {location ~ *. (Css | gif | ico | jpeg? J | js [on] | p | | png | svg | tcc | xml] $ {off access_log; Add_header cache-control "public"; Add_header Pragma "Public"; 365D expires; Log_not_found off; Tcp_nodelay off; Open_file_cache max = 16 inactive = 600s; # 10 min open_file_cache_errors on; Open_file_cache_min_uses2; Open_file_cache_valid 300s; # 5 minutes} try_files $ ur_gunicorn; } Location @ Unicorn {add_header} X-ProxyCache $ upstream_cache_status; The end of the era; Proxy_cache proxy; Proxy_cache_bypass $ nocache; Proxy_cache_key "$ request_method @ $ scheme: $ $ server_name: $ server_port $ ur $ args"; Proxy_cache_lock on; Proxy_cache_lock_timeout 2000; Proxy_cache_use_stale error timeout invalid_header update http_500; Proxy_cache_valid 200 302 1m; Proxy_cache_valid 301 1D; Proxy_cache_valid no 5s; Proxy_ http_version 1.1; Proxy_ignore_headers cache-control termination; Proxy_max_temp_file_size 1m; Proxy_no_cache $ nocache; Proxy_redirect closed; Host $ proxy_set_header host; Proxy_set_header X-Forward- $ proxy_add_x_forwarded_for; Proxy_set_header X-real-IP $ remote_adder; Proxy_pass http: // gun; }}   

    and answer your other questions:

    1. upstream directive to any * _ pass Can be used to simplify your NGN configuration and instructions for load balancing conditions. If you have more than one gunman server, then you can do something like: upstream guns {server http: // gunicorn1; Server http: // bandocon 2; } Server {location {proxy_app gunquarn; }}
      1. Set from nginx to auto worker_processes if your NGN version already has the auto option The use of the quantity of your NGNX worker procedures is nothing to do with the procedure procedure of your GNORNON application. And of course, even if you are only supplying fixed files, determining the correct amount of worker processes will increase the total amount of requests that can handle your NGNX and it will be recommended to set it up if your NGN If the version does not have an auto option, then set it in its actual physical CPU calculation or in the actual physical CPU core calculation
      2. I have a sample configuration for caching responses from my Gunnorne application server and open file cache of Unix based system for stable files. I think it is very clear to fix things. If you want me to explain some specific instructions in great detail, just leave a comment and I will edit my answer.

  • No comments:

    Post a Comment