Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions roles/cs.nginx-magento/templates/magento_server_body.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ location /rest/ {
}

location /pub/ {
location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
location ~ ^/pub/media/(downloadable|customer|import|custom_options|theme_customization/.*\.xml) {
deny all;
}

Expand Down Expand Up @@ -150,7 +150,7 @@ location /static/ {
}
{% endif %}

location ~* \.(html|ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|json)$ {
location ~* \.(ico|jpg|jpeg|png|gif|svg|svgz|webp|avif|avifs|js|css|eot|ttf|otf|woff|woff2|html|json|webmanifest|swf)$ {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
Expand Down Expand Up @@ -209,7 +209,7 @@ location /media/ {
deny all;
}

location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|mp4)$ {
location ~* \.(ico|jpg|jpeg|png|gif|svg|svgz|webp|avif|avifs|js|css|eot|ttf|otf|woff|woff2|swf|mp4)$ {
add_header Cache-Control "public";
add_header X-Frame-Options "SAMEORIGIN";
expires {{ nginx_static_files_expires }};
Expand Down Expand Up @@ -238,8 +238,18 @@ location /media/import/ {
deny all;
}

location /media/custom_options/ {
deny all;
}

location /errors/ {
location ~* \.xml$ {
deny all;
}
}

# PHP entry point for main application
location ~ (resize|index|get|static|report|404|503)\.php$ {
location ~ ^/(resize|index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
try_files $uri =404;

if ($request_uri ~ ^/rest/.*$) {
Expand Down Expand Up @@ -271,19 +281,6 @@ location ~ (resize|index|get|static|report|404|503)\.php$ {
include {{ nginx_magento_fastcgi_pass_include_path}};
}

location ~ cron\.php {
try_files $uri =404;

auth_basic "Cron Authentication";
auth_basic_user_file /etc/nginx/htpasswd;

set $PHP_MEMORY_LIMIT {{ magento_cron_request_php_memory_limit }};
set $PHP_MAX_EXECUTION_TIME {{ magento_cron_request_php_max_execution_time }};

fastcgi_index cron.php;
include {{ nginx_magento_fastcgi_pass_include_path}};
}

{% if mageops_php_file_cache_web %}
location {{ php_opcache_precompile_path }} {
allow 127.0.0.1;
Expand Down Expand Up @@ -317,6 +314,6 @@ location {{ custom.path_pattern }} {
}
{% endfor %}

location ~ .*\.php$ {
location ~* (\.php$|\.phtml$|\.htaccess$|\.htpasswd$|\.git) {
deny all;
}