#nginx #configuration #magento2 #varnish #php-7.4
Вопрос:
Magento 2.4.2 Ubuntu 18.04 Nginx PHP7.4-FPM Кэш лака были урегулированы, но когда я открываю http://timetoskins.com, он загружает файл вместо открытой домашней страницы Magento.
Когда я открою https://timetoskins.com, он показывает домашнюю страницу.
на /etc/nginx/сайтах-доступно/timetoskins.conf, было установлено 8080 и 443 порта.
Как я могу показать домашнюю страницу в http://timetoskins.com?
Какой параметр необходимо настроить, чтобы предотвратить загрузку файлов?
Кроме того, https://timetoskins.com/.user.ini, он загружает файл .user.ini вместо страницы с ошибкой 500/404.
Кэш лака тоже не работает.
Как я могу устранить эту ошибку?
server {
# if ($host = timetoskins.com) {
# return 301 https://$host$request_uri;
# } # managed by Certbot
# if ($host = www.timetoskins.com) {
# return 301 https://$host$request_uri;
# } # managed by Certbot
listen *:8080;
server_name timetoskins.com www.timetoskins.com ;
set $MAGE_ROOT /home/hosting/site/timetoskins_m2;
set $MAGE_RUN_CODE base;
set $MAGE_RUN_TYPE website;
include /home/hosting/site/timetoskins_m2/nginx.conf.sample;
}
## Example configuration:
upstream fastcgi_backend_timetoskins {
server unix:/run/php/php7.4-fpm.sock;
}
server {
listen 443 ssl http2;
server_name timetoskins.com www.timetoskins.com ;
set $MAGE_RUN_CODE base;
set $MAGE_RUN_TYPE website;
set $MAGE_ROOT /home/hosting/site/timetoskins_m2;
# if ($host = timetoskins.com) {
# return 301 https://www.$host$request_uri;
# } # managed by Certbot
# include /vagrant/magento2/nginx.conf.sample;
# }
#
root $MAGE_ROOT/pub;
index index.php;
autoindex off;
charset UTF-8;
error_page 404 403 = /errors/404.php;
rewrite ^/index.php/rest/V1/integration/admin/token /rest/V1/integration/admin/token last;
rewrite /blog/admin/?$ /blog/wp-login.php break;
rewrite /blog/admin/register/?$ /blog/wp-login.php?action=register break;
rewrite /blog/admin/lostpassword/?$ /blog/wp-login.php?action=lostpassword break;
location ~ .user.ini$ {
deny all;
}
location ^~ /blog {
if ($host != timetoskins.com) {
return 404;
}
index index.php;
alias /home/hosting/site/wp-timetoskins-skins;
try_files $uri $uri/ @rewrite_blog;
location ~ .php(/.*)? {
expires off;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
#fastcgi_pass unix:/run/php/php7.2-fpm-hosting.sock;
fastcgi_split_path_info ^(?:/blog)(. .php)(.*);
fastcgi_index index.php;
fastcgi_read_timeout 18000; #set phpscript executing timeout
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* ^. .(jpg|jpeg|gif|css|png|js|ico|xml|txt|svg|webp)$ {
access_log off;
expires max;
}
}
# Your blog location
location @rewrite_blog {
rewrite /blog /blog/index.php?q=$uriamp;$args;
}
# PHP entry point for setup application
location ~* ^/setup($|/) {
root $MAGE_ROOT;
location ~ ^/setup/index.php {
fastcgi_pass fastcgi_backend_timetoskins;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param PHP_FLAG "session.auto_start=off n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=2048M n max_execution_time=600";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^/setup/(?!pub/). {
deny all;
}
location ~ ^/setup/pub/ {
add_header X-Frame-Options "SAMEORIGIN";
}
}
# PHP entry point for update application
location ~* ^/update($|/) {
root $MAGE_ROOT;
location ~ ^/update/index.php {
fastcgi_split_path_info ^(/update/index.php)(/. )$;
fastcgi_pass fastcgi_backend_timetoskins;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
# Deny everything but index.php
location ~ ^/update/(?!pub/). {
deny all;
}
location ~ ^/update/pub/ {
add_header X-Frame-Options "SAMEORIGIN";
}
}
location / {
if ($request_uri ~ ^/(.*).html$) { return 302 /$1; }
rewrite ^/default/(.*) /$1 permanent;
#remove index.php from url
rewrite ^/index.php/(.*) /$1 permanent;
try_files $uri $uri/ /index.php$is_args$args;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Ssl-Offloaded "1";
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 443;
# # proxy_pass http://timetoskins.com:80;
# # proxy_pass http://127.0.0.1:80;
# # proxy_redirect http://localhost:80 https://timetoskins.com;
proxy_connect_timeout 86400;
proxy_send_timeout 86400;
proxy_read_timeout 86400;
send_timeout 86400;
client_max_body_size 50m;
client_body_buffer_size 16k;
}
location /pub/ {
location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*.xml) {
deny all;
}
alias $MAGE_ROOT/pub/;
add_header X-Frame-Options "SAMEORIGIN";
}
location /static/ {
# Uncomment the following line in production mode
# expires max;
# Remove signature of the static files that is used to overcome the browser cache
location ~ ^/static/version {
rewrite ^/static/(version[^/] /)?(.*)$ /static/$2 last;
}
location ~* .(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|json)$ {
add_header Cache-Control "public";
add_header X-Frame-Options "SAMEORIGIN";
expires 1y;
if (!-f $request_filename) {
rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
}
}
location ~* .(zip|gz|gzip|bz2|csv|xml)$ {
add_header Cache-Control "no-store";
add_header X-Frame-Options "SAMEORIGIN";
expires off;
if (!-f $request_filename) {
rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
}
}
if (!-f $request_filename) {
rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
}
add_header X-Frame-Options "SAMEORIGIN";
}
location /media/ {
try_files $uri $uri/ /get.php$is_args$args;
location ~* .(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|webp)$ {
add_header Cache-Control "public";
add_header X-Frame-Options "SAMEORIGIN";
expires 1y;
try_files $uri $uri/ /get.php$is_args$args;
}
location ~* .(zip|gz|gzip|bz2|csv|xml)$ {
add_header Cache-Control "no-store";
add_header X-Frame-Options "SAMEORIGIN";
expires off;
try_files $uri $uri/ /get.php$is_args$args;
}
add_header X-Frame-Options "SAMEORIGIN";
}
# asset/dynamic/assets/m/iult/f/cfg.css/
location = /asset/dynamic/assets/m/iult/f/cfg.css { expires off; }
location /media/customer/ {
deny all;
}
location /media/downloadable/ {
deny all;
}
location /media/import/ {
deny all;
}
# PHP entry point for main application
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check|phpinfo|jsonfeed).php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend_timetoskins;
fastcgi_buffers 1024 4k;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param PHP_FLAG "session.auto_start=off n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=2048M n max_execution_time=18000";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
#remove index.php
# rewrite ^(.*)$ /index.php;
}
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/xml rss
image/svg xml;
gzip_vary on;
# Banned locations (only reached if the earlier PHP entry point regexes don't match)
location ~* (.php$|.htaccess$|.git) {
deny all;
}
ssl_certificate /etc/letsencrypt/live/timetoskins.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/timetoskins.com/privkey.pem; # managed by Certbot
}