Skip to content

Instantly share code, notes, and snippets.

@mdpuma
Last active October 10, 2022 08:22
Show Gist options
  • Save mdpuma/db089e5f108f7d4dc457 to your computer and use it in GitHub Desktop.
Save mdpuma/db089e5f108f7d4dc457 to your computer and use it in GitHub Desktop.
nginx + apache, http to https redirect
# cat httpd.conf
SetEnvIf X-Forwarded-Proto https HTTPS=on
# cat .htaccess
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
Require all denied
Require ip 185.181.228.28
Require ip 95.65.41.30
SetEnvIf REQUEST_URI "^/admin/" PROTECTED
<RequireAny>
<RequireAll>
Require not env PROTECTED
Require all granted
</RequireAll>
<RequireAll>
AuthType Basic
AuthName "Password Protected"
AuthUserFile /home/hydrosystems/public_html/admin/.htpasswd
Require valid-user
</RequireAll>
</RequireAny>
ErrorDocument 401 "Authorisation Required"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment