Guest User

Untitled

a guest
Jun 25th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 7.29 KB | None | 0 0
  1. map $http_x_forwarded_proto $fastcgi_https {
  2.     default $https;
  3.     http '';
  4.     https on;
  5. }
  6.  
  7. upstream php {
  8.   server unix:/run/php/php7.3-fpm.sock;
  9. }
  10. server {
  11.  
  12.     server_name _;
  13.     root /home/user/www; ## <-- Your only path reference.
  14.  
  15.     access_log /home/user/logs/access.log;
  16.     error_log /home/user/logs/error.log;
  17.  
  18.     real_ip_header X-Forwarded-For;
  19.     set_real_ip_from 10.0.0.0/16;
  20.  
  21.  
  22.     location /elb-status {
  23.     access_log off;
  24.         return 200 'Health OK';
  25.     # because default content-type is application/octet-stream,
  26.         # browser will offer to "save the file"...
  27.     # the next line allows you to see it in the browser so you can test
  28.         add_header Content-Type text/plain;
  29.     }
  30.     error_page 404 = /404;
  31.  
  32.     location / {
  33.        error_page 404 = /node/896;
  34.        include /etc/nginx/snippets/redirects.conf;
  35.        location ~* /system/files/ {
  36.             include fastcgi.conf;
  37.             fastcgi_param QUERY_STRING q=$uri&$args;
  38.             fastcgi_param SCRIPT_NAME /index.php;
  39.             fastcgi_param SCRIPT_FILENAME $document_root/index.php;
  40.             fastcgi_pass php;
  41.             log_not_found off;
  42.         }
  43.  
  44.         location ~* /files/private/ {
  45.             internal;
  46.         }
  47.  
  48.         location ~* /files/styles/ {
  49.             access_log off;
  50.             expires 30d;
  51.             try_files $uri @drupal;
  52.         }
  53.  
  54.         location ~* /files/.+\.txt {
  55.             access_log off;
  56.             expires 30d;
  57.             tcp_nodelay off;
  58.             open_file_cache off;
  59.             open_file_cache_valid 45s;
  60.             open_file_cache_min_uses 2;
  61.             open_file_cache_errors off;
  62.         }
  63.  
  64.         location ~* /files/advagg_css/ {
  65.             expires max;
  66.             add_header ETag '';
  67.             add_header Last-Modified 'Wed, 20 Jan 1988 04:20:42 GMT';
  68.             add_header Accept-Ranges '';
  69.         add_header  Cache-Control "max-age=31449600, no-transform, public";
  70.             location ~* /files/advagg_css/css[_[:alnum:]]+\.css$ {
  71.                 access_log off;
  72.                 try_files $uri $uri/ @drupal;
  73.             }
  74.         }
  75.  
  76.         location ~* /files/advagg_js/ {
  77.             expires max;
  78.             add_header ETag '';
  79.             add_header Last-Modified 'Wed, 20 Jan 1988 04:20:42 GMT';
  80.             add_header Accept-Ranges '';
  81.         add_header  Cache-Control "max-age=31449600, no-transform, public";
  82.             location ~* /files/advagg_js/js[_[:alnum:]]+\.js$ {
  83.                 access_log off;
  84.                 try_files $uri $uri/ @drupal;
  85.             }
  86.         }
  87.  
  88.         location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|xml|otf|ttf|eot|woff|woff2|svg|svgz)$ {
  89.             access_log off;
  90.             expires 30d;
  91.             tcp_nodelay off;
  92.             open_file_cache off;
  93.             open_file_cache_valid 45s;
  94.             open_file_cache_min_uses 2;
  95.             open_file_cache_errors off;
  96.             location ~* ^.+\.svgz$ {
  97.                 gzip off;
  98.                 add_header Content-Encoding gzip;
  99.             }
  100.         }
  101.  
  102.         location ~* /admin/reports/hacked/.+/diff/ {
  103.             try_files $uri @drupal;
  104.         }
  105.  
  106.         location ~* /rss.xml {
  107.             add_header X-Test 'test always';
  108.             try_files $uri @drupal-no-args;
  109.         }
  110.  
  111.         location ~* /sitemap.xml {
  112.             try_files $uri @drupal;
  113.         }
  114.  
  115.  
  116.         location ~* ^.+\.(?:pdf|pptx?)$ {
  117.             expires 30d;
  118.             tcp_nodelay off;
  119.         }
  120.  
  121.  
  122.         location ~* ^(?:.+\.(?:htaccess|make|txt|engine|inc|info|install|module|profile|po|pot|sh|.*sql|test|theme|tpl(?:\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
  123.             return 404;
  124.         }
  125.  
  126.         try_files $uri @drupal;
  127.     }
  128.  
  129.  
  130.  
  131.     location @drupal {
  132.         include fastcgi.conf;
  133.         fastcgi_param QUERY_STRING $query_string;
  134.         fastcgi_param SCRIPT_NAME /index.php;
  135.         fastcgi_param SCRIPT_FILENAME $document_root/index.php;
  136.         fastcgi_pass php;
  137.         fastcgi_param SERVER_NAME $host;
  138.         fastcgi_param HTTP_X_GEOIP_COUNTRY $geoip2_data_country_code;
  139.         fastcgi_param HTTP_X_GeoIP_CountryIP $realip;
  140.     }
  141.  
  142.     location @drupal-no-args {
  143.         include fastcgi.conf;
  144.         fastcgi_param QUERY_STRING q=$uri;
  145.         fastcgi_param SCRIPT_NAME /index.php;
  146.         fastcgi_param SCRIPT_FILENAME $document_root/index.php;
  147.         fastcgi_pass php;
  148.         fastcgi_param SERVER_NAME $host;
  149.         fastcgi_param HTTP_X_GEOIP_COUNTRY $geoip2_data_country_code;
  150.         fastcgi_param HTTP_X_GeoIP_CountryIP $realip;
  151.     }
  152.  
  153.     location = /index.php {
  154.         fastcgi_pass php;
  155.         fastcgi_param SERVER_NAME $host;
  156.         fastcgi_param HTTP_X_GEOIP_COUNTRY $geoip2_data_country_code;
  157.         fastcgi_param HTTP_X_GeoIP_CountryIP $realip;
  158.     }
  159.  
  160.     location = /core/install.php {
  161.         fastcgi_pass php;
  162.         fastcgi_param SERVER_NAME $host;
  163.         fastcgi_param HTTP_X_GEOIP_COUNTRY $geoip2_data_country_code;
  164.         fastcgi_param HTTP_X_GeoIP_CountryIP $realip;
  165.     }
  166.  
  167.     location ~* ^/core/authorize.php {
  168.         include fastcgi.conf;
  169.         fastcgi_param QUERY_STRING $args;
  170.         fastcgi_param SCRIPT_NAME /core/authorize.php;
  171.         fastcgi_param SCRIPT_FILENAME $document_root/core/authorize.php;
  172.         fastcgi_pass php;
  173.         fastcgi_param SERVER_NAME $host;
  174.         fastcgi_param HTTP_X_GEOIP_COUNTRY $geoip2_data_country_code;
  175.         fastcgi_param HTTP_X_GeoIP_CountryIP $realip;
  176.     }
  177.  
  178.     location = /core/modules/statistics/statistics.php {
  179.         fastcgi_pass php;
  180.         fastcgi_param SERVER_NAME $host;
  181.         fastcgi_param HTTP_X_GEOIP_COUNTRY $geoip2_data_country_code;
  182.         fastcgi_param HTTP_X_GeoIP_CountryIP $realip;
  183.     }
  184.  
  185.     location = /cron {
  186.         include fastcgi.conf;
  187.         fastcgi_param QUERY_STRING $args;
  188.         fastcgi_param SCRIPT_NAME /index.php;
  189.         fastcgi_param SCRIPT_FILENAME $document_root/index.php;
  190.         fastcgi_pass php;
  191.         fastcgi_param SERVER_NAME $host;
  192.         fastcgi_param HTTP_X_GEOIP_COUNTRY $geoip2_data_country_code;
  193.         fastcgi_param HTTP_X_GeoIP_CountryIP $realip;
  194.     }
  195.  
  196.     location ~* ^/update.php {
  197.         include fastcgi.conf;
  198.         fastcgi_param QUERY_STRING $args;
  199.         fastcgi_param SCRIPT_NAME /update.php;
  200.         fastcgi_param SCRIPT_FILENAME $document_root/update.php;
  201.         fastcgi_pass php;
  202.         fastcgi_param SERVER_NAME $host;
  203.         fastcgi_param HTTP_X_GEOIP_COUNTRY $geoip2_data_country_code;
  204.         fastcgi_param HTTP_X_GeoIP_CountryIP $realip;
  205.     }
  206.  
  207.     location ^~ /.bzr {
  208.         return 404;
  209.     }
  210.  
  211.     location ^~ /.git {
  212.         return 404;
  213.     }
  214.  
  215.     location ^~ /.hg {
  216.         return 404;
  217.     }
  218.  
  219.     location ^~ /.svn {
  220.         return 404;
  221.     }
  222.  
  223.     location ^~ /.cvs {
  224.         return 404;
  225.     }
  226.  
  227.     location ^~ /patches {
  228.         return 404;
  229.     }
  230.  
  231.     location ^~ /backup {
  232.         return 404;
  233.     }
  234.  
  235.     location = /robots.txt {
  236.         access_log off;
  237.         try_files $uri @drupal-no-args;
  238.     }
  239.  
  240.     location = /favicon.ico {
  241.         expires 30d;
  242.         try_files /favicon.ico @empty;
  243.     }
  244.  
  245.     location ~* ^/.well-known/ {
  246.         allow all;
  247.     }
  248.  
  249.     location @empty {
  250.         expires 30d;
  251.         empty_gif;
  252.     }
  253.  
  254.     location ~* ^.+\.php$ {
  255.         return 404;
  256.     }
  257.  
  258. }
Add Comment
Please, Sign In to add comment