Apache Web site, using Nginx for reverse proxy (1 IP binding multiple domain names, corresponding to multiple websites) solutions

Source: Internet
Author: User
Tags server port

The same port cannot be monitored by two programs at the same time. So change your mind. Some websites run under Nginx under the same server, and some websites run under Apache coexistence. Solution Ideas:

Nginx as a proxy server and Web server use, nginx monitoring 80 port, Apache listening to the port except 80, I temporarily use 8080 port.

Solution:
    • In Linux once built environment has installed nginx and Apache because the default port is: 80
    • The server port of the general customer request defaults to 80 so nginx as a static page port setting: 80; Apache set Port to: 8080 (Modify listen:8080 in httpd.conf file)
    • Apache under the website:

Add in nginx.conf

 server {listen 80; server_name Www.one.ityangs . CN one.ityangs.cn;location /{proxy_pass http://127.0.0.1:8080 ; Proxy_redirect off; Proxy_set_header Host  $host; Proxy_set_header x-Real-ip  $remote _addr; Proxy_set_header X -forwarded-for  $proxy _add _x_forwarded_for; } } 
    • Nginx under the website:

Add in nginx.conf

server {Listen80; server_name. ityangs. CN www. the. ityangs. cn; Root/www/two; Location/{Index Index. HTML Index. htm index. php; if (!-e $request _filename) {rewrite ^ (. *) $/index. php?s=$1 last;Break; } error_page404/var/www/html/404.html; } location ~ \. PHP (. *) $ {Fastcgi_pass127.0.0.1: 9000.php) (/?. +) $; Fastcgi_param path_info $fastcgi _path_info 

actual configuration:
Apache configuration file, httpd.conf configuration

nginx configuration file, nginx.conf configuration

Apache web site, using Nginx for reverse proxy (1 IP binding multiple domain names, corresponding to multiple websites) solution

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.