Advertisement
Guest User

Untitled

a guest
Apr 29th, 2019
1,650
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 3.95 KB | None | 0 0
  1. user www-data;
  2. pid /run/nginx.pid;
  3. worker_processes auto;
  4. worker_rlimit_nofile 65535;
  5.  
  6. events {
  7.   multi_accept on;
  8.   worker_connections 65535;
  9. }
  10.  
  11. error_log  /var/log/nginx/error.log error;
  12.  
  13.  
  14. http {
  15.  
  16.   include     /etc/nginx/mime.types;
  17.   default_type  text/html;
  18.   charset utf-8;
  19.   sendfile on;
  20.   tcp_nopush on;
  21.   tcp_nodelay on;
  22.   keepalive_timeout 65536;
  23.   gzip on;
  24.   gzip_vary on;
  25.   gzip_proxied any;
  26.   gzip_comp_level 6;
  27.   gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
  28.  
  29.   log_format postdata $request_body;
  30.   access_log  /var/www/production-api.host/public/access.log postdata;
  31.  
  32.   server {
  33. set $base /var/www;
  34.         
  35.  
  36.     listen 127.0.0.1:8888;  
  37.     server_name production-api.host;
  38.     root $base/production-api.host/public;
  39.  
  40.     location ~ [^/]\.php(/|$) {
  41.     internal;
  42.    
  43.       fastcgi_split_path_info ^(.+\.php)(/.+)$;
  44.       set $_fastcgi_path_info $fastcgi_path_info;
  45.       try_files $fastcgi_script_name =404;
  46.       include fastcgi_params;
  47.           
  48.       fastcgi_pass      $server_addr:9000;
  49.       fastcgi_index      index.php;
  50.       fastcgi_buffers      8 16k;
  51.       fastcgi_buffer_size    32k;
  52.  
  53.       fastcgi_param DOCUMENT_ROOT    $realpath_root;
  54.       fastcgi_param SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
  55.       fastcgi_param PATH_INFO      $_fastcgi_path_info;
  56.       fastcgi_param PHP_ADMIN_VALUE  "open_basedir=$base/:/usr/lib/php/:/tmp/";
  57.     }
  58.   }
  59.  
  60.   # different host and port from production api
  61.   include include/dev_api.conf;  
  62.  
  63.   server {
  64.      set $base /var/www;
  65.     listen *:80;
  66.     server_name production.host;
  67.     root $base/production.host/public;
  68.         add_header 'Content-Security-Policy' "default-src 'self'; script-src 'unsafe-inline';";
  69.  
  70.     location ~/api/user/((?<userid>[^.]*))?$ {
  71.       proxy_pass http://127.0.0.1:8888;
  72.       proxy_set_header Host "production-api.host";
  73.       proxy_set_header X-Forwarded-For $remote_addr;
  74.             proxy_set_header X-User-Id $userid;
  75.             if ($http_origin ~* ((^https:\/\/www\.production\.host)|(^https:\/\/production\.host)$)) {
  76.                 add_header 'Access-Control-Allow-Origin' "$http_origin";
  77.                 add_header 'Access-Control-Allow-Credentials' 'true';
  78.             }
  79.     }
  80.  
  81.     location /static {
  82.         alias /prod_static/;
  83.     }
  84.         location /management/ {
  85.             access_by_lua_block {
  86.                 if ngx.header["X-Managed"] ~= nil and ngx.header["X-Managed"] ~= "secured") then
  87.                     ngx.exit(ngx.HTTP_FORBIDDEN)
  88.                 end
  89.             }
  90.         }
  91.   }
  92.  
  93.   server {
  94.  
  95.     listen *:8080;
  96.     server_name development.env;
  97.     root $base/development.env/public;
  98.  
  99.     location /api/ {
  100.  
  101.       proxy_pass http://127.0.0.1:1337/;
  102.       proxy_set_header Host "development-api.host";
  103.       proxy_set_header X-Forwarded-For $remote_addr;
  104.  
  105.             location ~/user/((?<userid>[^.]*))?$ {
  106.                 add_header X-Debug-User-Id $userid;
  107.             }
  108.       }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement