Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Configuration of Apache

Shulou Source: shulou.com Published: 2022-06-01 04:28:23 10月03日 Update

The first virtual host in the virtual host configuration file

Vim vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

# ServerAdmin webmaster@dummy-host.example.com

DocumentRoot "/ tmp/123"

ServerName 111.com

After saving

Mkdir / tmp/123

Chmod 600 / tmp/123

Apache domain name 301 jump

Add to the virtual host configuration file

Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

# RewriteEngine on

RewriteCond% {HTTP_HOST} ^ bbb.com

RewriteRule ^ / (. *) $https://cache.yisu.com/upload/information/20200310/68/125221.jpg$" p_w_picpath-request

SetEnvIf Request_URI ". *\ .jpg $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .png $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .bmp $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .swf $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .js $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .css $" p_w_picpath-request

CustomLog "| / usr/local/apache2/bin/rotatelogs-l / usr/local/apache2/logs/test.com__%Y%m%d_log 86400" combined environs filled with wicked picpathic request

2.2 Apache configure static cache

Modify virtual host configuration file

Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

ErrorLog "/ usr/local/apache2/logs/tset.com-error_log"

SetEnvIf Request_URI ". *\ .gif $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .jpg $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .png $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .bmp $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .swf $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .js $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .css $" p_w_picpath-request

CustomLog "| / usr/local/apache2/bin/rotatelogs-l / usr/local/apache2/logs/test.com__%Y%m%d_log 86400" combined environs filled with wicked picpathic request

ExpiresActive on

ExpiresByType p_w_picpath/gif "access plus 1 days"

ExpiresByType p_w_picpath/jpeg "access plus 24 hours"

ExpiresByType p_w_picpath/png "access plus 24 hours"

ExpiresByType txt/ccs "now plus 2 hours"

ExpiresByType application/x-javascript "now plus 2 hours"

ExpiresByType application/javascript "now plus 2 hours"

ExpiresByType application/x-shockwave-flash "now plus 2 hours"

ExpiresDefault "now plus 0 min"

2.3 Apache configuration hotlink protection

Modify the virtual host configuration file and add

Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

SetEnvIfNoCase Referer "^ http://.*\.aaa\.com" local_ref

SetEnvIfNoCase Referer ". *\ .bbb\ .com" local_ref

SetEnvIfNoCase Referer "^ $" local_ref

Order Allow,Deny

Allow from env=local_ref

Apache access control

Add to the virtual host profile

Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

AllowOverride None

Order allow,deny

Allow from all

Deny from 1.1.1.1

Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

Php_admin_flag engine off

Order deny,allow

Deny from all

Apache prohibits the assignment of user_agent

User_agent search engine

Restricted access to curl and chrome browsers

RewriteEngine on is the equivalent of a switch

RewriteCond% {HTTP_USER_AGENT} ^. * curl.* [NC,OR]

RewriteCond% {HTTP_USER_AGENT} ^. * chrome* [NC]

RewriteRule. *-[F]

Apache restricts a directory through rewrite

RewriteCond% {REQUEST_URI} ^. * / tmp/.* [NC]

RewriteRule. *-[F]

Apache--admin encryption

Add to the virtual host profile

Vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

AllowOverride AuthConfig

AuthName "aaaaa"

AuthType Basic

AuthUserFile / data/.htpasswd

Require valid-user

Create an authenticated user for Apache after saving

/ usr/local/apache2/bin/htpasswd-c / data/.htpasswd user

-

General profile

# ServerAdmin webmaster@dummy-host.example.com

DocumentRoot "/ tmp/123"

ServerName 111.com

# ServerAdmin webmaster@dummy-host.example.com

DocumentRoot "/ data/www/"

ServerName aaa.com

ServerAlias bbb.com

# ErrorLog "logs/test2.com-error_log"

# CustomLog "logs/test2.com_log" combined

ErrorLog "/ usr/local/apache2/logs/tset.com-error_log"

SetEnvIf Request_URI ". *\ .gif $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .jpg $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .png $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .bmp $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .swf $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .js $" p_w_picpath-request

SetEnvIf Request_URI ". *\ .css $" p_w_picpath-request

CustomLog "| / usr/local/apache2/bin/rotatelogs-l / usr/local/apache2/logs/test.com__%Y%m%d_log 86400" combined environs filled with wicked picpathic request

ExpiresActive on

ExpiresByType p_w_picpath/gif "access plus 1 days"

ExpiresByType p_w_picpath/jpeg "access plus 24 hours"

ExpiresByType p_w_picpath/png "access plus 24 hours"

ExpiresByType txt/ccs "now plus 2 hours"

ExpiresByType application/x-javascript "now plus 2 hours"

ExpiresByType application/javascript "now plus 2 hours"

ExpiresByType application/x-shockwave-flash "now plus 2 hours"

ExpiresDefault "now plus 0 min"

SetEnvIfNoCase Referer "^ http://.*\.aaa\.com" local_ref

SetEnvIfNoCase Referer ". *\ .bbb\ .com" local_ref

SetEnvIfNoCase Referer "^ $" local_ref

Order Allow,Deny

Allow from env=local_ref

RewriteEngine on

RewriteCond% {HTTP_HOST} ^ bbb.com

RewriteRule ^ / (. *) $http://aaa.com/$1 [Rust 301m L]

RewriteEngine on

RewriteCond% {REQUEST_URI} ^. * / tmp/.* [NC]

RewriteRule. *-[F]

AllowOverride AuthConfig

AuthName "aaaaa"

AuthType Basic

AuthUserFile / data/.htpasswd

Require valid-user

AllowOverride None

Order allow,deny

Allow from all

Deny from 1.1.1.1

Php_admin_flag engine off

Order deny,allow

Deny from all

AllowOverride AuthConfig

AuthName "aaaaa"

AuthType Basic

AuthUserFile / data/.htpasswd

Require valid-user

RewriteEngine on

RewriteCond% {HTTP_USER_AGENT} ^. * curl.* [NC,OR]

RewriteCond% {HTTP_USER_AGENT} ^. * chrome* [NC]

RewriteRule. *-[F]

Tags: Configuration hosts virtual hosts files restrictions domain names engines search engines browsers users directories caches static China Canada encryption control search browsing anti-theft verification Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Linux vpn MySQL