Advertisement
Guest User

Ddev Typo3 Nginx Conf with TYPO3 Application Context set

a guest
Feb 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 3.37 KB | None | 0 0
  1. # Set https to 'on' if x-forwarded-proto is https
  2. map $http_x_forwarded_proto $fcgi_https {
  3.     default off;
  4.     https on;
  5. }
  6.  
  7. server {
  8.     listen 80; ## listen for ipv4; this line is default and implied
  9.     listen [::]:80 default ipv6only=on; ## listen for ipv6
  10.     # The NGINX_DOCROOT variable is substituted with
  11.     # its value when the container is started.
  12.     root $NGINX_DOCROOT;
  13.     index index.php index.htm index.html;
  14.  
  15.     # Make site accessible from http://localhost/
  16.     server_name _;
  17.  
  18.     # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
  19.     sendfile off;
  20.     error_log /var/log/nginx/error.log info;
  21.     access_log /var/log/nginx/error.log;
  22.  
  23.     location / {
  24.         # First attempt to serve request as file, then
  25.         # as directory, then fall back to index.html
  26.         try_files $uri $uri/ /index.php?q=$uri&$args;
  27.     }
  28.  
  29.     location @rewrite {
  30.         # For D7 and above:
  31.         # Clean URLs are handled in drupal_environment_initialize().
  32.         rewrite ^ /index.php;
  33.     }
  34.  
  35.     # Handle image styles for Drupal 7+
  36.     location ~ ^/sites/.*/files/styles/ {
  37.         try_files $uri @rewrite;
  38.     }
  39.  
  40.     # pass the PHP scripts to FastCGI server listening on socket
  41.     location ~ \.php$ {
  42.         try_files $uri =404;
  43.         fastcgi_split_path_info ^(.+\.php)(/.+)$;
  44.         fastcgi_pass unix:/run/php-fpm.sock;
  45.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  46.         fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  47.         fastcgi_index index.php;
  48.         include fastcgi_params;
  49.         fastcgi_intercept_errors on;
  50.         # fastcgi_read_timeout should match max_execution_time in php.ini
  51.         fastcgi_read_timeout 240;
  52.         fastcgi_param SERVER_NAME $host;
  53.         fastcgi_param HTTPS $fcgi_https;
  54.         fastcgi_param TYPO3_CONTEXT Development;
  55.     }
  56.  
  57.     # Expire rules for static content
  58.     # Feed
  59.     location ~* \.(?:rss|atom)$ {
  60.         expires 1h;
  61.     }
  62.  
  63.     # Media: images, icons, video, audio, HTC
  64.     location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
  65.         expires 1M;
  66.         access_log off;
  67.         add_header Cache-Control "public";
  68.     }
  69.  
  70.     # Prevent clients from accessing hidden files (starting with a dot)
  71.     # This is particularly important if you store .htpasswd files in the site hierarchy
  72.     # Access to `/.well-known/` is allowed.
  73.     # https://www.mnot.net/blog/2010/04/07/well-known
  74.     # https://tools.ietf.org/html/rfc5785
  75.     location ~* /\.(?!well-known\/) {
  76.         deny all;
  77.     }
  78.  
  79.     # Prevent clients from accessing to backup/config/source files
  80.     location ~* (?:\.(?:bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op])|~)$ {
  81.         deny all;
  82.     }
  83.  
  84.     ## Regular private file serving (i.e. handled by Drupal).
  85.     location ^~ /system/files/ {
  86.         ## For not signaling a 404 in the error log whenever the
  87.         ## system/files directory is accessed add the line below.
  88.         ## Note that the 404 is the intended behavior.
  89.         log_not_found off;
  90.         access_log off;
  91.         expires 30d;
  92.         try_files $uri @rewrite;
  93.     }
  94.  
  95.     ## provide a health check endpoint
  96.     location /healthcheck {
  97.         access_log off;
  98.         return 200;
  99.     }
  100.  
  101.     error_page 400 401 /40x.html;
  102.     location = /40x.html {
  103.             root   /usr/share/nginx/html;
  104.     }
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement