Здравствуйте! Помогите пожалуйста настроить редиректы на nginx+php-fpm, а именно:
Редирект с ip адреса на домен;
Редирект на сайтмэп с языковым префиксом (ua/sitemap.xml - с этим конфигом сайтмэпы с языковым префиксом не отдаются даже через ua/index.php?route=extension/feed/google_sitemap_fast). ua/index.php?route работает только при добавлении
if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?_route_=$1 last; }
, но не работает при этом /ua/sitemap.xml;
И правило на удаление лишних /// (почему-то только на главной странице они не удаляются, на остальных страницах все норм).
Вот мой конфиг, частично сгенерированый isp manager. Буду очень благодарен за помощь!
server {
server_name site.com www.site.com;
charset UTF-8;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/site.com/*.conf;
access_log /var/www/httpd-logs/site.com.access.log;
error_log /var/www/httpd-logs/site.com.error.log notice;
ssi on;
return 301 https://$host:443$request_uri;
set $root_path /var/www/user/data/www/site.com;
root $root_path;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 7;
gzip_buffers 16 8k;
gzip_min_length 256;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
location / {
try_files $uri $uri/ @opencart;
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|mp3|ogg|mpe?g|avi|woff2|webp)$ {
expires 365d;
log_not_found off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
try_files $uri $uri/ @fallback;
}
location ~* ^.+\.(js|css|zip|gz|bz2?|rar|swf)$ {
expires 14d;
log_not_found off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
try_files $uri $uri/ @fallback;
}
rewrite ^/sitemap.xml$ /index.php?route=extension/feed/google_sitemap_fast last;
rewrite ^/ua/sitemap.xml$ /ua/index.php?route=extension/feed/google_sitemap_fast last;
rewrite ^/en/sitemap.xml$ /en/index.php?route=extension/feed/google_sitemap_fast last;
rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last;
rewrite ^/system/download/(.*) /index.php?route=error/not_found last;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location ~* \.(engine|inc|info|ini|install|log|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
deny all;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
listen 111.111.111.11:80 default_server;
listen [2a05:470:0:f43a::2]:80 default_server;
location @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f
[email protected]";
fastcgi_pass unix:/var/www/php-fpm/user.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
}
server {
server_name site.com www.site.com;
ssl_certificate "/var/www/httpd-cert/user/site.com_le3.crtca";
ssl_certificate_key "/var/www/httpd-cert/user/site.com_le3.key";
ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
charset UTF-8;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/site.com/*.conf;
access_log /var/www/httpd-logs/site.com.access.log;
error_log /var/www/httpd-logs/site.com.error.log notice;
ssi on;
set $root_path /var/www/user/data/www/site.com;
root $root_path;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 7;
gzip_buffers 16 8k;
gzip_min_length 256;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
location / {
try_files $uri $uri/ @opencart;
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|mp3|ogg|mpe?g|avi|woff2|webp)$ {
expires 365d;
log_not_found off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
try_files $uri $uri/ @fallback;
}
location ~* ^.+\.(js|css|zip|gz|bz2?|rar|swf)$ {
expires 14d;
log_not_found off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
try_files $uri $uri/ @fallback;
}
rewrite ^/sitemap.xml$ /index.php?route=extension/feed/google_sitemap_fast last;
rewrite ^/ua/sitemap.xml$ /ua/index.php?route=extension/feed/google_sitemap_fast last;
rewrite ^/en/sitemap.xml$ /en/index.php?route=extension/feed/google_sitemap_fast last;
rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last;
rewrite ^/system/download/(.*) /index.php?route=error/not_found last;
if ($host ~* www\.(.*)) {
set $host_without_www $1;
rewrite ^(.*)$ https://$host_without_www$1 permanent;
}
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location ~* \.(engine|inc|info|ini|install|log|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
deny all;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
add_header Strict-Transport-Security "max-age=31536000;";
listen 111.111.111.11:443 ssl default_server http2;
listen [2a05:470:0:f43a::2]:443 ssl default_server http2;
location @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f
[email protected]";
fastcgi_pass unix:/var/www/php-fpm/user.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
}