是否可以使用htpasswd或某种htaccess规则来保护特定的端口号。例如,我在端口5533上运行数据库探查器,并希望阻止公众访问它。
由于
答案 0 :(得分:1)
试试这个:
RewriteCond %{SERVER_PORT} !5533 # If port is 5533
RewriteRule ^ - [E=NO_AUTH:1] # We're setting the env variable for any request
# because condition works only on next line
Order deny,allow
Deny from all
AuthType basic
AuthName "You have to be logged in"
AuthUserFile "/etc/httpd/conf.d/.htpasswd" #Your htpasswd path
Require valid-user
Allow from env=NO_AUTH # If env variable was set
# we can pass the request only through authentication
Satisfy Any