Use of ApacheHTTP server ------ Binding of address and port)

Source: Internet
Author: User
Use of the ApacheHTTP server ------ Binding of the address and port -- Linux Enterprise Application-Linux server application information. For details, see the following. Configure the address and port specified by the Apache listener.
Top
Overview
Related module commands

* Core
* Mpm_common



*
* Listen

When Apache is started, it will bind the address and port on the local machine and wait for the request to enter. By default, it listens to all addresses on the local machine. However, when you need to listen for a combination of specific addresses, ports, or addresses and ports, or make different responses to different IP addresses, host names, and ports (such as using virtual hosts, it must be explicitly specified.

The Listen Command tells the server to receive requests only from a specific port (or a combination of address and port. If the Listen command only specifies the port, the server listens to all IP addresses. If the address + port combination is specified, the server only listens to requests from the specific port on this specific address. Multiple Listen commands can be used to specify multiple addresses and ports for listening.

For example, if the server accepts requests from ports 80 and 8000 at the same time, you can write as follows:

Listen 80
Listen 8000.

Accept the combination of two specified addresses and ports:

Listen 192.170.2.1: 80
Listen 192.170.2.5: 8000

The IPv6 address must be enclosed in square brackets:

Listen [2001: db8: a00: 20ff: fea7: ccea]: 80
Top
Special considerations for IPv6

More and more platforms are beginning to support IPv6. APR also supports IPv6. Apache can obtain IPv6 Sockets and process requests sent through IPv6.

An issue that often puzzles Apache administrators is whether IPv6 Sockets can simultaneously process IPv4 and IPv6 connections. IPv6 Sockets are used to map IPv6 to IPv4 addresses (IPv4-mapped IPv6 addresses) when processing IPv4 connections, which is allowed by default on most platforms, freeBSD, NetBSD, and OpenBSD are disabled by default. Even on these platforms that are disabled by default, Apache can use special compilation options to change this behavior.

On Some platforms (such as Linux and Tru64), the only way to process both IPv6 and IPv4 is to use mapped addresses ). If you want Apache to process both IPv4 and IPv6 connections with minimal sockets, you must use the IPv6 address mapped to IPv4, that is, you must specify the -- enable-v4-mapped compilation option.

On platforms other than FreeBSD, NetBSD, and OpenBSD, -- enable-v4-mapped is the default value at compile time. Therefore, the Apache you are using may be compiled in this way.

To make Apache only process IPv4 connections, you only need to specify the IPv4 address for all Listen commands no matter what your platform or APR supports, as shown below:

Listen 0.0.0.0: 80
Listen 192.170.2.1: 80

If your platform supports address ing from IPv6 to IPv4, but you want Apache to use different sockets to process IPv4 and IPv6 connections respectively (that is, disable address ing ), you must explicitly specify the -- disable-v4-mapped compilation option. Note: -- The disable-v4-mapped defaults on FreeBSD, NetBSD, and OpenBSD.
Top
How to work with a VM

The Listen command does not implement a virtual host. It only tells the main server which addresses and ports to Listen. If no The server treats all requests equally. Command, the server will make different responses to different addresses and ports. To implement a VM, you must first tell the server which addresses and ports to listen to, and then create . Note: If the segment is set to the address and port that the server does not listen to, the segment is invalid.

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.