Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configuration of Apache

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

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]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report