【发布时间】:2013-03-05 06:06:50
【问题描述】:
我使用 Nginx 作为我的 Apache 注入的反向代理,并作为一项安全功能,它阻止除 localhost 之外的所有人访问 phpmyadmin、webalizer 等,但使用 nginx 会使 Apache 认为它是 localhost,因此它会公开显示给所有人。
<LocationMatch "^/(?i:(?:xampp|security|phpmyadmin|licenses|webalizer|server-status|server-info))">
Order deny,allow
Deny from all
Allow from ::1 127.0.0.0/8 \
fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \
fe80::/10 169.254.0.0/16
ErrorDocument 403 /
</LocationMatch>
我需要把上面的规则模式匹配正则表达式变成如下。
location /phpmyadmin {
proxy_pass htt://127.0.0.1:8080/phpmyadmin;
allow 127.0.0.1;
deny all;
}
非常感谢任何熟悉 Nginx 正则表达式的人的帮助。
以下方法有效,但会破坏对搜索引擎友好的正常站点 url,例如 domain.com/forums/server-info
location ~ /(xampp|security|phpmyadmin|licenses|webalizer|server-status|server-info) {
deny all;
}
【问题讨论】: