github.com/ddev/ddev@v1.23.2-0.20240519125000-d824ffe36ff3/pkg/ddevapp/webserver_config_assets/nginx-site-magento.conf (about)

     1  # ddev magento config
     2  
     3  #ddev-generated
     4  # If you want to take over this file and customize it, remove the line above
     5  # and ddev will respect it and won't overwrite the file.
     6  # See https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#custom-nginx-configuration
     7  
     8  server {
     9      listen 80 default_server;
    10      listen 443 ssl default_server;
    11  
    12      root {{ .Docroot }};
    13  
    14      ssl_certificate /etc/ssl/certs/master.crt;
    15      ssl_certificate_key /etc/ssl/certs/master.key;
    16  
    17      include /etc/nginx/monitoring.conf;
    18  
    19      index index.php index.htm index.html;
    20  
    21      # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
    22      sendfile off;
    23      error_log /dev/stdout info;
    24      access_log /var/log/nginx/access.log;
    25  
    26      if ($mage_run_code = '') {
    27          set $mage_run_code '';
    28      }
    29  
    30      if ($mage_run_type = '') {
    31          set $mage_run_type store;
    32      }
    33  
    34      location / {
    35          absolute_redirect off;
    36          try_files $uri $uri/ /index.php$is_args$args;
    37      }
    38  
    39      location /api {
    40          rewrite ^/api/rest /api.php?type=rest last;
    41      }
    42  
    43      # pass the PHP scripts to FastCGI server listening on socket
    44      location ~ \.php$ {
    45          try_files $uri =404;
    46          fastcgi_split_path_info ^(.+\.php)(/.+)$;
    47          fastcgi_pass unix:/run/php-fpm.sock;
    48          fastcgi_buffers 16 16k;
    49          fastcgi_buffer_size 32k;
    50          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    51          fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    52          fastcgi_index index.php;
    53          include fastcgi_params;
    54          fastcgi_intercept_errors on;
    55          # fastcgi_read_timeout should match max_execution_time in php.ini
    56          fastcgi_read_timeout 10m;
    57          fastcgi_param SERVER_NAME $host;
    58          fastcgi_param HTTPS $fcgi_https;
    59          fastcgi_param MAGE_RUN_CODE $mage_run_code;
    60          fastcgi_param MAGE_RUN_TYPE $mage_run_type;
    61      }
    62  
    63      # Expire rules for static content
    64  
    65      # Media: images, icons, video, audio, HTC
    66      location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|webp|htc)$ {
    67          expires 1M;
    68          access_log off;
    69          add_header Cache-Control "public";
    70      }
    71  
    72      # Prevent clients from accessing hidden files (starting with a dot)
    73      # This is particularly important if you store .htpasswd files in the site hierarchy
    74      # Access to `/.well-known/` is allowed.
    75      # https://www.mnot.net/blog/2010/04/07/well-known
    76      # https://tools.ietf.org/html/rfc5785
    77      location ~* /\.(?!well-known\/) {
    78          deny all;
    79      }
    80  
    81      # Prevent clients from accessing to backup/config/source files
    82      location ~* (?:\.(?:bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op])|~)$ {
    83          deny all;
    84      }
    85  
    86      include /etc/nginx/common.d/*.conf;
    87      include /mnt/ddev_config/nginx/*.conf;
    88  }