سؤال

Is it possible to use htpasswd, or some kind of htaccess rule to secure a specific port number. For example I have database profiler running on port 5533, and would like to stop the public accessing it.

Thanks

هل كانت مفيدة؟

المحلول

Try this:

    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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top