RumanticK

Untitled

Mar 30th, 2017
5,368
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 3.00 KB | None | 0 0
  1. # emulate two additional (non-standard) CGI/SSI environment variables named SCRIPT_URL and SCRIPT_URI
  2. # http://httpd.apache.org/docs/2.0/rewrite/rewrite_intro.html#EnvVar
  3. map $request_uri $script_path {
  4.     default $request_uri;
  5.     ~^(?<script_filename>.*)(\?.*)$ $script_filename;
  6.     ~^(?<script_filename>.*)(\?.*)?$ $script_filename;
  7. }
  8.  
  9. ## fpm project
  10. server {
  11.     #
  12.     # Host name mask
  13.     #
  14.     server_name _;
  15.     listen 80;
  16.  
  17.     #
  18.     # Projects definitions
  19.     #
  20.     set $project_root "/home/web/core/uws/web";
  21.     set $project_socket "unix:/var/run/php5-fpm.sock";
  22.    
  23.     root $project_root;
  24.  
  25.     #
  26.     # some secure
  27.     # disable expose of .svn, .git and .htaccess/.htpasswd files
  28.     #
  29.     location ~* \.(svn|git)/ {
  30.         return 444;
  31.     }
  32.     location ~* ^\.(ht.+)$ {
  33.         return 444;
  34.     }
  35.  
  36.     location / {
  37.         # try to serve file directly, fallback to app.php
  38.         try_files $uri /app.php$is_args$args;
  39.     }
  40.     # DEV
  41.     # This rule should only be placed on your development environment
  42.     # In production, don't include this and don't deploy app_dev.php or config.php
  43.     location ~ ^/(app_dev|config)\.php(/|$) {
  44.         fastcgi_pass unix:/var/run/php5-fpm.sock;
  45.         fastcgi_split_path_info ^(.+\.php)(/.*)$;
  46.         include fastcgi_params;
  47.         # When you are using symlinks to link the document root to the
  48.         # current version of your application, you should pass the real
  49.         # application path instead of the path to the symlink to PHP
  50.         # FPM.
  51.         # Otherwise, PHP's OPcache may not properly detect changes to
  52.         # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
  53.         # for more information).
  54.         fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  55.         fastcgi_param DOCUMENT_ROOT $realpath_root;
  56.     }
  57.     # PROD
  58.     location ~ ^/app\.php(/|$) {
  59.         fastcgi_pass unix:/var/run/php5-fpm.sock;
  60.         fastcgi_split_path_info ^(.+\.php)(/.*)$;
  61.         include fastcgi_params;
  62.         # When you are using symlinks to link the document root to the
  63.         # current version of your application, you should pass the real
  64.         # application path instead of the path to the symlink to PHP
  65.         # FPM.
  66.         # Otherwise, PHP's OPcache may not properly detect changes to
  67.         # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
  68.         # for more information).
  69.         fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  70.         fastcgi_param DOCUMENT_ROOT $realpath_root;
  71.         # Prevents URIs that include the front controller. This will 404:
  72.         # http://domain.tld/app.php/some-path
  73.         # Remove the internal directive to allow URIs like this
  74.         internal;
  75.     }
  76.  
  77.     # return 404 for all other php files not matching the front controller
  78.     # this prevents access to other php files you don't want to be accessible.
  79.     location ~ \.php$ {
  80.       return 404;
  81.     }
  82.  
  83.     error_log /var/log/nginx/project_error.log;
  84.     access_log /var/log/nginx/project_access.log;
  85.  
  86. }
Advertisement