Thread Closed

#1
is it possible to password protect a directory based on a condition like
RewriteEngine On
RewriteCond %{SERVER_PORT} ^85
RewriteRule #require password

different external port as port 80 is in use on another machine
router forwards port 85 to port 80
ReportQuote
#2
Have you got access to the httpd.conf? Easy enough to do it there, but I don't think it can be made to work in the .htaccess.

Have I helped you? Do you like my add-ons?
Would you consider donating to show your appreciation for my efforts?

/images/paypal.png
ReportQuote
#3
Technically no I don't since it is owned by root and I am not root but, I have sudo so I can
What do I need to do in that file (and its location)

Edited by az on Feb. 5, 2011, 1:21 a.m.

ReportQuote
#4
Well where it is depends on the computer. Several Linux distributions put it in different places. Google is your friend.

But I was thinking you could use it to create a <VirtualHost> that listens on port 85, and then just put the standard need password rules in there. Too complex to explain the details in a forum post, you will need to do your own research for that.

Have I helped you? Do you like my add-ons?
Would you consider donating to show your appreciation for my efforts?

/images/paypal.png
ReportQuote
#5
none worked Idea?

/etc/apache2/sites-available/default
<VirtualHost *:80>
	ServerAdmin webmaster@localhost

	DocumentRoot /var/www
	<Directory />
		Options FollowSymLinks
		AllowOverride All
	</Directory>
	<Directory /var/www/>
		Options Indexes FollowSymLinks MultiViews ExecCGI
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>

	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride All
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>

	ErrorLog /var/log/apache2/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
<VirtualHost *:85>
        <Directory /var/www>
		deny from all
        </Directory>
</VirtualHost>

/etc/apache2/httpd.conf
<VirtualHost *:85>
        <Directory /var/www>
		deny from all
        </Directory>
</VirtualHost>

Edited by az on Feb. 6, 2011, 9:07 a.m.

ReportQuote
#6
Remove the redirect from the router and make it connect directly to your computer on port 85 now?

EDIT: Actually maybe http://httpd.apache.org/docs/2.0/bind.html

Have I helped you? Do you like my add-ons?
Would you consider donating to show your appreciation for my efforts?

/images/paypal.png
ReportQuote
#7
Thanks, it works
/etc/apache2/ports.conf
NameVirtualHost *:80
NameVirtualHost *:85
Listen 80
Listen 85

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>
/etc/apache2/sites-available/default
<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

/etc/apache2/sites-available/default
<VirtualHost *:80>
	ServerAdmin webmaster@localhost

	DocumentRoot /var/www
	<Directory />
		Options FollowSymLinks
		AllowOverride All
	</Directory>
	<Directory /var/www/>
		Options Indexes FollowSymLinks MultiViews ExecCGI
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>

	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride All
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>

	ErrorLog /var/log/apache2/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
<VirtualHost *:85>
	DocumentRoot /var/www
        <Directory /var/www>
		AuthName "Authorization is required to access the scanner" 
		AuthType Basic 
		AuthUserFile /etc/apache2/users 
		AuthGroupFile /dev/null 
		require valid-user
        </Directory>
</VirtualHost>

Apache must be restarted after editing ports.conf and default
Now I just have to remember the password

Edited by az on Feb. 6, 2011, 6:23 p.m.

ReportQuote
#8
QUOTE:
Apache must be restarted after editing ports.conf and default

If it was a production server you would want to do a graceful restart. http://httpd.apache.org/docs/2.0/stopping.html#graceful

QUOTE:
Now I just have to remember the password

Yeah the hard part!

Have I helped you? Do you like my add-ons?
Would you consider donating to show your appreciation for my efforts?

/images/paypal.png
ReportQuote

Thread Closed