Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:services:server_services:webhosting:access_control_with_htaccess [2016/06/03 15:00] – [How to allow access for specific IP or IP-ranges] rlossin | en:services:server_services:webhosting:access_control_with_htaccess [2016/06/14 14:24] (current) – [How to allow access for specific IP or IP-ranges] rlossin | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Access Control With .Htaccess ====== | ||
+ | ===== What does .htaccess actually do? ===== | ||
+ | .htaccess-files are hidden files, which are processed by the Apache Webserver. Depending on the configuration of Apache2 the .htaccess-files can modify the behaviour of the webserver, e.g. by modifying values of modules (Rewrite, Expires, ...) . | ||
+ | ===== How to password-protection of files and directories ===== | ||
+ | Within the documentroot of your webspace-subscription the .htaccess-file can be used to password-protect a custom file or directory. To create a .htaccess-based login form just create a file called .htaccess via SFTP. Please make sure that the file is created in the document root of your webhosting-subscription (e.g. ''/ | ||
+ | |||
+ | **Example: | ||
+ | |||
+ | < | ||
+ | AuthName " | ||
+ | AuthType Basic | ||
+ | AuthUserFile / | ||
+ | require valid-user | ||
+ | </ | ||
+ | |||
+ | After creating this .htaccess-file move to the '' | ||
+ | |||
+ | ==== Use Shell To Generate .Htpasswd ==== | ||
+ | |||
+ | You can use a shell to auto-generate a valid .htpasswd-file. To do so, simply log into a shell and enter. | ||
+ | |||
+ | < | ||
+ | | ||
+ | </ | ||
+ | |||
+ | You are asked to enter a password, which is stored as a hash. | ||
+ | |||
+ | On login.gwdg.de enter | ||
+ | |||
+ | < | ||
+ | | ||
+ | </ | ||
+ | |||
+ | |||
+ | **Example: | ||
+ | < | ||
+ | username: | ||
+ | </ | ||
+ | |||
+ | ==== Use Online Tools To Generate .Htpasswd ==== | ||
+ | |||
+ | If you do not want to use shell to generate .htpassword, | ||
+ | |||
+ | | ||
+ | |||
+ | **Example: | ||
+ | < | ||
+ | username: | ||
+ | </ | ||
+ | |||
+ | ===== How to allow access for specific IP or IP-ranges ===== | ||
+ | To grant access to users from specific IP-addresses or IP-ranges, you need to create a .htaccess-file in the document root of your webhosting-subscription. | ||
+ | |||
+ | **Example (single IP/Apache 2.2):** | ||
+ | |||
+ | < | ||
+ | order deny,allow | ||
+ | deny from all | ||
+ | allow from 123.123.123.123 | ||
+ | </ | ||
+ | |||
+ | **Example (IP-range/ | ||
+ | |||
+ | < | ||
+ | order deny,allow | ||
+ | deny from all | ||
+ | allow from 123.123.123.0/ | ||
+ | </ | ||
+ | |||
+ | **Example (single IP/Apache 2.4)** | ||
+ | |||
+ | < | ||
+ | Require ip 123.123.123.123 | ||
+ | </ |