Example of configuring server proxy Apache on Windows Server

Source: Internet
Author: User
Tags require


Start with the local Apache configuration example:
The main configuration file varies from person to person. If you need to rewrite it, do not forget to enable it:


LoadModule rewrite_module modules/mod_rewrite.so

It is not recommended that the content be written in the main directory. Use a sub-file to introduce it:

 

# Virtual hosts
Include etc/extra/httpd-vhosts.conf
# Various default settings
Include etc/extra/httpd-default.conf
The default logging configuration is used. If the time-out period is for the server to be deprecated, adjust it as appropriate.


#
# This configuration file reflects default settings for Apache HTTP Server.
#
# You may change these, but chances are that you may not need.
#
 
#
# Timeout: The number of seconds before between es and sends time out.
#
Timeout55
 
#
# KeepAlive: Whether or not to allow persistent connections (more
# One request per connection). Set to "Off" to deactivate.
#
KeepAlive On
 
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# During a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
Maxkeepaliverequest100
 
#
# KeepAliveTimeout: Number of seconds to wait for the next request from
# Same client on the same connection.
#
KeepAliveTimeout10
 
#
# UseCanonicalName: Determines how Apache constructs self-referencing
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# By the client. When set "On", Apache will use the value of
# ServerName directive.
#
UseCanonicalName Off
 
#
# AccessFileName: The name of the file to look for in each directory
# For additional configuration directives. See also the AllowOverride
# Directive.
#
AccessFileName. htaccess
 
#
# ServerTokens
# This directive configures what you return as the Server HTTP response
# Header. The default is 'full' which sends information about the OS-Type
# And compiled in modules.
# Set to one of: Full | OS | Minor | Minimal | Major | Prod
# Where Full conveys the most information, and Prod the least.
#
ServerTokens Prod
 
#
# Optionally add a line containing the server version and virtual host
# Name to server-generated pages (internal error documents, FTP directory
# Listings, mod_status and mod_info output etc., but not CGI generated
# Documents or custom error documents ).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of: On | Off | EMail
#
ServerSignature Off
 
#
# HostnameLookups: Log the names of clients or just their IP addresses
# E.g., www.apache.org (on) or 204.62.129.132 (off ).
# The default is off because it 'd be overall better for the net if people
# Had to knowinugly turn this feature on, since enabling it means that
# Each client request will result in at least one lookup request to
# Nameserver.
#
HostnameLookups Off
 
#
# Set a timeout for how long the client may take to send the request header
# And body.
# The default for the headers is header = 20-40, MinRate = 500, which means wait
# For the first byte of headers for 20 seconds. If some data arrives,
# Increase the timeout corresponding to a data rate of 500 bytes/s, but not
# Above 40 seconds.
# The default for the request body is body = 20, MinRate = 500, which is the same
# But has no upper limit for the timeout.
# To disable, set to header = 0 body = 0
#
<IfModule reqtimeout_module>
RequestReadTimeout header = 20-40, MinRate = 500 body = 20, MinRate = 500
</IfModule>

If your site does not use the fast-cgi method, you can set it as follows:


# Www.111cn.net
<VirtualHost *: 80>
<Directory "/Users/soulteary/Blog/www.111cn.net/public">
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Require all granted
</Directory>
 
<IfModule dir_module>
DirectoryIndex index. php index.html
</IfModule>
 
<Files ". ht *">
Require all denied
</Files>
 
# If you need to adjust the mime-type, you can
# AddType text/x-component. htc
 
LogLevel warn
 
ServerAdmin webmaster@soulteary.com
DocumentRoot "/Users/soulteary/Blog/www.111cn.net/public"
ServerName www.111cn.net
ServerAlias soulteary.com
ErrorLog "/Users/soulteary/Blog/www.111cn.net/logs/www.111cn.net-error.log"
CustomLog "/Users/soulteary/Blog/www.111cn.net/logs/www.111cn.net-access.log" combined
</VirtualHost>
If you want to work with fast-cgi programs such as hhvm

# Www.111cn.net
<VirtualHost *: 80>
ServerAdmin developer@www.111cn.net
DocumentRoot "/yourpath/www.111cn.net/public"
ServerName www.111cn.net
ServerAlias soulteary.com
 
<Directory "/yourpath/www.111cn.net/public">
Options Indexes FollowSymLinks ExecCGI Includes
Options-MultiViews
AllowOverride All
Require all granted
DirectoryIndex index. php index.html
</Directory>
 
ErrorLog "/yourpath/www.111cn.net/logs/www.111cn.net-error_log"
CustomLog "/yourpath/www.111cn.net/logs/www.111cn.net-access_log" common
 
<IfModule mod_proxy.c>
ProxyPass/fcgi: // 127.0.0.1: 9000/yourpath/www.111cn.net/public/
ProxyPassMatch ^/(. * \. php (/.*)?) $ Fcgi: // 127.0.0.1: 9000/yourpath/www.111cn.net/public/#1
ProxyVia Off
</IfModule>
 
</VirtualHost>

By default, when a site is accessed by IP address, you can disable access, or allow access by a specified IP address or UA (such as linode logview). If it is an information site, you can consider directing traffic to the site.


# Access prohibited by default
<VirtualHost *: 80>
# IP address monitored by your server
ServerName12.34.56.78
# How many IP addresses does the server have?
# ServerAliase 12.34.56.79
# Write a default record to avoid information related to other sites
ServerAdmin webmaster @ localhost
# Define a directory
DocumentRoot/var/www/html
<Directory/>
Order deny, allow
Deny from all
</Directory>
 
# You can turn to visit your site with a tail
RedirectMatch ^/. * $ http://www.111cn.net /? Ref = ip
ErrorLog $ {APACHE_LOG_DIR}/error. log
CustomLog $ {APACHE_LOG_DIR}/access. log combined
</VirtualHost>

There is a configuration detail about Apache, that is, because the program performs sequential parsing and execution, you need to first define document directory and define the index file to prevent the program from failing to locate the error.
Some children's shoes often see their websites crawled by spider or scanner. You may wish to add some simple rules to filter such crawlers.


# Blocking bots, spammers, harvesters...
SetEnvIfNoCase User-Agent "Download Ninja 2.0" block_bad_bots
SetEnvIfNoCase User-Agent "Fetch API Request" block_bad_bots
SetEnvIfNoCase User-Agent "HTTrack" block_bad_bots
SetEnvIfNoCase User-Agent "ia_archiver" block_bad_bots
SetEnvIfNoCase User-Agent "JBH Agent 2.0" block_bad_bots
SetEnvIfNoCase User-Agent "QuepasaCreep" block_bad_bots
SetEnvIfNoCase User-Agent "Program policware 1.0.0" block_bad_bots
SetEnvIfNoCase User-Agent "TestBED.6.3" block_bad_bots
SetEnvIfNoCase User-Agent "WebAuto" block_bad_bots
SetEnvIfNoCase User-Agent "WebCopier" block_bad_bots
SetEnvIfNoCase User-Agent "Wget/1.8.2" block_bad_bots
SetEnvIfNoCase User-Agent "Offline Explorer" block_bad_bots
SetEnvIfNoCase User-Agent "Franklin Locator" block_bad_bots
SetEnvIfNoCase User-Agent "LWP: Simple" block_bad_bots
SetEnvIfNoCase User-Agent "Larbin" block_bad_bots
SetEnvIfNoCase User-Agent "Rufus Web Miner" block_bad_bots
SetEnvIfNoCase User-Agent "Port Huron Labs" block_bad_bots
SetEnvIfNoCase User-Agent "Sphider" block_bad_bots
SetEnvIfNoCase User-Agent "voyager/1.0" block_bad_bots
SetEnvIfNoCase User-Agent "DynaWeb" block_bad_bots
SetEnvIfNoCase User-Agent "EmailCollector/1.0" block_bad_bots_bot
SetEnvIfNoCase User-Agent "EmailSiphon" block_bad_bots_bot
SetEnvIfNoCase User-Agent "EmailWolf 1.00" block_bad_bots_bot
SetEnvIfNoCase User-Agent "ExtractorPro" block_bad_bots_bot
SetEnvIfNoCase User-Agent "Crescent Internet ToolPak" block_bad_bots_bot
SetEnvIfNoCase User-Agent "CherryPicker/1.0" block_bad_bots_bot
SetEnvIfNoCase User-Agent "CherryPickerSE/1.0" block_bad_bots_bot
SetEnvIfNoCase User-Agent "CherryPickerElite/1.0" block_bad_bots_bot
SetEnvIfNoCase User-Agent "NICErsPRO" block_bad_bots_bot
SetEnvIfNoCase User-Agent "WebBandit/2.1" block_bad_bots_bot
SetEnvIfNoCase User-Agent "WebBandit/3.50" block_bad_bots_bot
SetEnvIfNoCase User-Agent "webbandit/4.00.0" block_bad_bots_bot
SetEnvIfNoCase User-Agent "WebEMailExtractor/1.0B" block_bad_bots_bot
SetEnvIfNoCase User-Agent "autoemailspider" block_bad_bots_bot
SetEnvIfNoCase User-Agent "^ libwww-perl" block_bad_bots
SetEnvIfNoCase User-Agent "^ WordPress/2 \. 0 \. 2" block_bad_bots
SetEnvIfNoCase User-Agent "^ Opera/9 \. 0 \ (Windows NT5 \. 1; U; en \)" block_bad_bots
SetEnvIfNoCase User-Agent "^ PycURL/7 \. 15 \. 5 $" block_bad_bots
SetEnvIfNoCase User-Agent "^ TurnitinBot" block_bad_bots
SetEnvIfNoCase User-Agent "^ West Wind Internet Protocols" block_bad_bots
SetEnvIfNoCase User-Agent "^ POE: Component: Client: HTTP/" block_bad_bots
SetEnvIfNoCase User-Agent "^ User-Agent: Mozilla/4.0" block_bad_bots
SetEnvIfNoCase User-Agent "netforex" block_bad_bots
SetEnvIfNoCase User-Agent "^ SMBot/" block_bad_bots
SetEnvIfNoCase User-Agent "^ Mozilla/4.0 \ (compatible; MSIE4 \. 0; Windows NT ;\. \. \. \. \. \. /1 \. 0 \) $ "block_bad_bots
SetEnvIfNoCase User-Agent "envolk" block_bad_bots
SetEnvIfNoCase User-Agent "^ TMCrawler" block_bad_bots
SetEnvIfNoCase User-Agent "^ Opera/6 \. 01 \ (Windows ME; U \) \ [en \]" block_bad_bots
SetEnvIfNoCase User-Agent "^ NASA Search" block_bad_bots
SetEnvIfNoCase User-Agent "^ TrackBack/" block_bad_bots
SetEnvIfNoCase User-Agent "^ Mozilla/4 \. 0 \ (compatible; MSIE6 \. 0; Windows NT5 \. 0; Maxthon \) $" block_bad_bots
SetEnvIfNoCase User-Agent "QihooBot" block_bad_bots
SetEnvIfNoCase User-Agent "^ Gigabot/..." block_bad_bots
SetEnvIfNoCase User-Agent "K-Meleon/0 \. 8" block_bad_bots
SetEnvIfNoCase User-Agent "Twiceler" block_bad_bots
SetEnvIfNoCase User-Agent "^ NSPlayer" block_bad_bots
SetEnvIfNoCase User-Agent "^ Microsoft URL Control" block_bad_bots
SetEnvIfNoCase User-Agent "^ InetURL" block_bad_bots
SetEnvIfNoCase User-Agent "DotBot" block_bad_bots
SetEnvIfNoCase User-Agent "YandexBot" block_bad_bots
SetEnvIfNoCase User-Agent "Nutch" block_bad_bots
SetEnvIfNoCase User-Agent "Mozilla/4 \. 0 \ (compatible; ICS \)" block_bad_bots
SetEnvIfNoCase User-Agent "Mozilla/3 \. 0 \ (compatible; Indy Library \)" block_bad_bots
 
<Directory/var/www/vhosts/>
Order Allow, Deny
Allow from all
Deny from env = block_bad_bots
</Directory>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.