Prompt login/password with .htaccess on Azure Container - azure

I'm looking for implementing an .htaccess on Azure Container, but I don't think this is the proper way to implement a request access on Azure Container, because this is maybe different from Apache?
I want to add this .htaccess for specifics files on container root. Here is my .htaccess file:
<FilesMatch "^(index|standalone|standalone-async|spa).html$">
AuthName "Dialog prompt"
AuthType Basic
AuthUserFile /.htpasswd
Require valid-user
</FilesMatch>
Am I on the good way? And is this the best way to implement a dialog prompt on Azure Container?
Regards.

this is maybe different from Apache?
Yes, it is and if you are using the Windows App Service with the php stack, it uses the IIS not the Apache and the .htaccess is only for Apache. So that's why asked you the web stack.
If you are using a Windows App Service, try to use the web.config from .htaccess by putting all the applicable rules.
If you are using a php on a Linux App Service, make sure to re-check the major version like in the given below reference.
It is important that where we are placing this .htaccess file.
The target file that begins with index or whateverpage & it ends with .html
<FilesMatch "^(index|whateverpage)\.html$">
AuthName "Dialog prompt"
AuthType Basic
AuthUserFile /.htpasswd
Require valid-user
</FilesMatch>
References:
Azure Web App Doesn’t Read HTAccess File,
Use of .htaccess file.

Related

Add basic auth (htpasswd) on the "index of" view but not on individual files

I have set up an FTP connection via ShareX to upload my screenshots to my own ftp.
So my screenshots are accessible at the url 'screenshots.mydomain.fr/myscreenshothash.png'.
And that's cool!
But according to the url 'screenshots.mydomain.fr' you can see the list of all my screenshots (the page Index of). And I'd like to block this page via an htpasswd without blocking access to the files ('screenshots.mydomain.fr/myscreenshothash.png')
What can I do?
My current .htaccess
AuthUserFile /home/XXL /.htpasswd
AuthGroupFile /dev/null
AuthName "Accès Restreint"
AuthType Basic
require valid-user
For the moment I have added a
Options -Indexes
in my htaccess to prevent access to the index of page and I made a listing of my files in a index.php files placed in a subfolder (in which I put the htaccess with htpasswd)

http authentication via htacces does not work on ubuntu

need a help with .htacces file to make http authentication.
I made .htacces and .htpasswd files due to tutorial on some web page, but it doesn't work.
.htacces file is very simple
AuthType Basic
AuthName "xxx"
AuthUserFile my/directory/path/
Require valid-user
Path is right, I checked it. Does anyone know what can be wrong please? Maybe there's something on ubuntu I should change or something.Thanks

How do I remove HTTP authentication on a website on a FreeBSD Server?

Sorry that I haven't done much of my own research but I do not know how to set up basic authentication, nevermind removing it!
Thanks.
EDIT:
Sorry, what was I thinking, its in httpd.conf or includes!
This is more a question for ServerFault, but I'm going to carry on and assume you're using Apache on FreeBSD.
The authentication is set in either the httpd.conf (main Apache configuration file) or a .htaccess file in the directory that serves the protected content.
In the httpd.conf file, you'll come across a Directory or Location statement which matches, respectively, either the physical filesystem directory where the protected content is stored, or the URI of the protected content.
In either case, the authentication is a set of lines beginning with Auth. Simply comment those out - if they're in the httpd.conf file, you'll need to restart your Apache server, if in a .htaccess file it should take effect right away.
Examples:
In httpd.conf, files in /srv/www/protected are protected by authentication:
<Directory /srv/www/protected>
AuthType basic
AuthName "My Protected Site"
...
</Directory>
Or, within the /srv/www/protected directory in a file called .htaccess:
AuthType basic
AuthName "My Protected Site"
...

.htpasswd under IIS - does it work?

I'm trying to password protect a directory on a server that's running IIS.
I've put the following in the .htaccess file in that directory -
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/.htpasswd
AuthGroupFile /dev/null
require valid-user
I've tried a whole bunch of different paths and although it's asking for a username and password it won't take it. I've tried using the path provided by _SERVER["PATH_TRANSLATED"] but that's no help either.
Is this a problem with my path, or does IIS just not support .htpasswd?
Helicon Ape (http://www.helicontech.com/ape naturally supports .htpasswd file with all these authentication options you’ve mentioned. The software also implements a bunch of other Apache-like features. As regarding authentication, you may also be interesting in these articles: http://helicontech.blogspot.com/search/label/mod_auth
Thank you.
IIS does not support .htpasswd or .htaccess.
Natively IIS does not support the htpasswd.
You can get IISPassword for IIS from here if you really want to use
similar files under IIS.

Combine URL rewriting (to force https) with http auth?

I have a domain, mattpotts.com and have set up a sub-domain dev.mattpotts.com for me to develop on and will then copy the files to the normal domain when they're ready to go.
My directory structure is as follows and dev.mattpotts.com points to dev/
+-public_html/
+-project1/
+-project2/
+-project3/
+-dev/
+-project1
+-project2
+-project3
I basically want to be able to go from http://mattpotts.com/project1 to https://dev.mattpotts.com/project1 by adding dev..
I have the following .htaccess in dev/ and it works, all this needs to do is force https.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} dev
RewriteRule ^(.*)$ https://dev.mattpotts.com$1 [R,L]
I want to force https so that I can securely use http auth on the directory. However, when I combine it with the following rules, it doesn't work. I have my .htpasswd set up but I've not even had the login form show up yet.
AuthType Basic
AuthName "Dev Protected Area"
AuthUserFile .htpasswd
Require valid-user
How can I successfully combine the to set of .htaccess rules?
Edit, very strange things are happening!
https://dev.mattpotts.com/project1/ displays 'hello!' from non dev version of site (note https)
http://dev.mattpotts.com/project1/ displays 'hello dev!' (as desired) from dev version. What's going on here?!
You've told us where your .htaccess file is, but you haven't told us where your .htpasswd file is. According to the Apache documentation on AuthUserFile:
Syntax: AuthUserFile file-path
File-path is the path to the user
file. If it is not absolute (i.e., if
it doesn't begin with a slash), it is
treated as relative to the ServerRoot.
So in other words, it is looking for the .htpasswd in somewhere like /etc/apache2/.htpasswd. So either move your .htpasswd file there, or make your directive contain an absolute path to the file, e.g.:
AuthType Basic
AuthName "Dev Protected Area"
AuthUserFile /home/mattpots.com/public_html/dev/.htpasswd
Require valid-user
However, for security reasons, I highly recommend keeping your .htpasswd file outside of your document root.
These issues should be independent of each other: do I understand correctly that the "force HTTPS" part works?
That said, AuthUserFile .htpasswd may be looking for .htpasswd in the wrong place. The easiest fix is to put the full path and name there, e.g. AuthUserFile /home/matt/www/public_html/dev/.htpasswd (or wherever you have the dev directory).

Resources