Jump to content


Photo

htaccess through port number


  • Please log in to reply
1 reply to this topic

#1 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 08 November 2005 - 12:27 AM

another question

Is it possible to popup an htaccess logon box for when someone tries to access a certain port number

So if someone tries to access stuff on port 8080
how do I restrict and authorize it


and I guess my next problem would be
how do I distinguish in Apache which port a folder is part of
if I have all my folders in htdocs (the web root) and I want say my images folder on port 8080
would I have to take it out the web root and put it in a folder in the apache root somewhere....what
how you see what I'm getting at?

btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png

#2 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 10 November 2005 - 10:37 PM

Is it possible to popup an htaccess logon box for when someone tries to access a certain port number

If you use a VirtualHost you can add the directives for basic authentication
<VirtualHost host:8080>
    AuthType Basic
    AuthName images
    AuthUserFile /path/to/pass_file
    require valid-user
</Virtualhost>

how do I distinguish in Apache which port a folder is part of
if I have all my folders in htdocs (the web root) and I want say my images folder on port 8080

In a .htaccess file in your root you could have the following
RewriteCond %{SERVER_PORT} !=8080
RewriteRule ^images/ - [F]
You should be able to use the following inside the VirtualHost directive to have the same VHost settings applied for access on the different ports. However, the %{SERVER_PORT} variable seems to be incorrectly filled with the port listed first in the directive.
<VirtualHost host:80 host:8080>
</VirtualHost>
I had to put multiple VHost directives for the port listed in %{SERVER_PORT}to be accurate. I haven't checked what happens in Apache 2.0, and I'm not using the most recent versions of either.

It may ultimately be better to put a section in the Vhost for port 80 to deny access to the directory instead of using the .htaccess file.

EDIT: Apache 2.0 apparently has the correct SERVER_PORT value when you use the Multiple listings of host:port in the Virtualhost.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users