Advertisement
Guest User

Untitled

a guest
Sep 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 3.13 KB | None | 0 0
  1. # http {
  2. #   ...
  3. #   ...
  4. #   merge_slashes off;
  5. # }
  6. # upstream your-backend {server unix:/var/run/php5-your-backend.sock;}
  7.  
  8. server {
  9.   server_name       i.DOMAIN.TLD;
  10.   location / {
  11.     proxy_pass      http://DOMAIN.TLD/i/;
  12.   }
  13. }
  14. server {
  15.   listen          80;
  16.   server_name     js.DOMAIN.TLD;
  17.   location / {
  18.     proxy_pass    http://DOMAIN.TLD/js/;
  19.   }
  20. }
  21. server {
  22.   server_name     www.DOMAIN.TLD;
  23.   return          301 $scheme://DOMAIN.TLD$request_uri;
  24. }
  25. server {
  26.   listen          80;
  27.   server_name     *.DOMAIN.TLD DOMAIN.TLD;
  28.   charset         utf-8;
  29.   root            /var/www/yoursite/www;
  30.   access_log      /var/log/nginx/yoursite-access.log;
  31.   error_log       /var/log/nginx/yoursite-error.log;
  32.   index           index.php index.html;
  33.   rewrite_log     on;
  34.  
  35.   location ~* ^/(adminka|manager|connectors|connectors-[_A-Z-a-z-0-9]+|_build)/ {
  36.     location ~ \.php$ {
  37.       try_files       $uri =404;
  38.  
  39.       include         fastcgi_params;
  40.       fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
  41.       fastcgi_pass    your-backend;
  42.     }
  43.     break;
  44.   }
  45.  
  46.   # Hide modx /core/ directory
  47.   location ~* ^/core/ {
  48.     # deny          all;
  49.     return          404;
  50.   }
  51.   # If file and folder not exists -->
  52.   location / {
  53.     try_files       $uri $uri/ @rewrite;
  54.   }
  55.   # Redirect from index.html file to folder name
  56.   location ~* ^(.*)/index\.html$ {
  57.     if ($request_uri ~* '^(.*)/index\.html$') {
  58.       # rewrite     ^(.*)/index\.html$ $scheme://$host$1 permanent;
  59.       rewrite       ^(.*)/index\.html$ $scheme://$host$1/ permanent;
  60.     }
  61.   }
  62.   # Redirect from index.php file to folder name
  63.   location ~* ^(.*)/index\.php$ {
  64.     if ($request_uri ~* '^(.*)/index\.php$') {
  65.       # rewrite     ^(.*)/index\.php$ $scheme://$host$1 permanent;
  66.       rewrite       ^(.*)/index\.php$ $scheme://$host$1/ permanent;
  67.     }
  68.     try_files       $uri =404;
  69.  
  70.     include         fastcgi_params;
  71.     fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
  72.     fastcgi_pass    your-backend;
  73.   }
  74.   # Remove double slashes in url. https://modx.pro/help/2386/#comment-69137
  75.   location ~ // {
  76.     rewrite         ^(.*)//+(.*)$ $1/$2 permanent;
  77.   }
  78.   # --> then redirect request to entry modx index.php
  79.   location @rewrite {
  80.     # add trailing slash
  81.     # rewrite       (.*[^/])$ :/// permanent;
  82.     # remove trailing slash
  83.     rewrite         (.*)/$ $scheme://$host$1 permanent;
  84.     rewrite         ^/(.*)$ /index.php?q=$1 last;
  85.   }
  86.   # PHP handler
  87.   location ~ \.php$ {
  88.     try_files       $uri =404;
  89.  
  90.     include         fastcgi_params;
  91.     fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
  92.     fastcgi_pass    your-backend;
  93.   }
  94.  
  95.   # Hide .htaccess/.htpassword files
  96.   location ~ /\.ht {
  97.     # deny          all;
  98.     return          404;
  99.   }
  100.  
  101.   # Custom error page
  102.   error_page 500 502 503 504 /50x.html;
  103.   location = /50x.html {
  104.     internal;
  105.   }
  106.   error_page 404 /404.html;
  107.   location = /404.html {
  108.     internal;
  109.   }
  110.   error_page 403 /403.html;
  111.   location = /403.html {
  112.     internal;
  113.   }
  114.  
  115.   # Include the basic h5bp config set
  116.   include h5bp/basic.conf;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement