Nginx位置块不';行不通
我试图将nginx服务器配置为以不同于所有其他请求的方式处理对/awstats的请求。我也为/fpm状态这样做了。然而,这个特定的位置似乎不起作用。我尝试了所有位置匹配的排列。确切的问题是位置“/awstats”也被重写为php url。有人能告诉我下面配置中的错误吗Nginx位置块不';行不通,nginx,Nginx,我试图将nginx服务器配置为以不同于所有其他请求的方式处理对/awstats的请求。我也为/fpm状态这样做了。然而,这个特定的位置似乎不起作用。我尝试了所有位置匹配的排列。确切的问题是位置“/awstats”也被重写为php url。有人能告诉我下面配置中的错误吗 server { listen 80; listen 443 ssl; ssl on; ssl_certificate /etc/ssl/bundle.crt; ssl_certificate_key /etc
server {
listen 80;
listen 443 ssl;
ssl on;
ssl_certificate /etc/ssl/bundle.crt;
ssl_certificate_key /etc/ssl/domain.key;
server_name domain.tld;
root /var/www/html/project/;
index index.php index.html index.htm;
location ^~ ^/awstats {
root /var/www/awstats/domain.tld/;
index awstats.domain.tld.html;
}
location ~ ^/awstats-icon/ {
alias /var/www/awstats/icon/;
}
location ~* \.tpl|\.ini|\.log|(?<!robots)\.txt$ {
deny all;
return 404;
}
location ~ ^/fpm_status {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass php-fpm;
allow 127.0.0.1;
allow 43.252.193.74;
allow 172.31.3.18;
deny all;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
rewrite ^/sitemap.xml$ /index.php?route=feed/google_sitemap last;
rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last;
rewrite ^/system/download/(.*) /index.php?route=error/not_found last;
if (!-f $request_filename){
set $rule_3 1$rule_3;
}
if (!-d $request_filename){
set $rule_3 2$rule_3;
}
if ($uri !~ ".*.(ico|gif|jpg|jpeg|png|js|css)"){
set $rule_3 3$rule_3;
}
rewrite ^/api/((?!apidoc).*) /index.php?route=api/$1 last;
rewrite ^/admin_api/((?!adminapidoc).*) /admin/index.php?route=admin_api/$1 last;
rewrite ^/((?!admin|favicon|awstats|fpm_status|robots)(.*)) /index.php?_route_=$1 last;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
access_log /var/log/nginx/domain.tld.access.log timed_combined;
服务器{
听80;
听443ssl;
ssl-on;
ssl_证书/etc/ssl/bundle.crt;
ssl\u证书\u密钥/etc/ssl/domain.key;
服务器名称domain.tld;
root/var/www/html/project/;
index.php index.html index.htm;
位置^ ~^/awstats{
root/var/www/awstats/domain.tld/;
索引awstats.domain.tld.html;
}
位置~^/awstats图标/{
别名/var/www/awstats/icon/;
}
位置~*\.tpl\.ini\.log(?
}您的位置语句似乎混淆了前缀位置和正则表达式位置语法:
location ^~ ^/awstats
^ ~
修饰符与前缀位置一起使用以更改其求值顺序,但这里您指定了一个正则表达式参数
使用以下任一选项:
location ^~ /awstats
或:
请参阅以了解详细信息。现在尝试了两种方法。遗憾的是,两种方法都不起作用。我甚至尝试了完全匹配。这也不起作用。
location ~ ^/awstats