Configure nginx reverse proxy Apache for different ports with the same IP address

Source: Internet
Author: User
Tags nginx reverse proxy

Configure nginx reverse proxy Apache for different ports with the same IP address (that is, nginx jumps to Apache)

 

Nginx and Apache have been installed in a Linux environment since the default port is 80.

Generally, the server port requested by the customer is 80 by default. Therefore, nginx serves as the static page port and is set to 80.

Set the Apache port to 8080 (modify listen: 8080 In the httpd. conf file)

How to jump:

Add in nginx. conf

  

location / {        proxy_pass              http://202.85.224.166: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;        }         

  

Code and

Server {
Listen 80;
SERVER_NAME localhost;

} Parallel positions

Then restart the Server Browser and enter http: // 202.85.224.166: 80; to see if it is redirected to the Apache htdocs/index.html page instead of the nginx welcome page.

 

What if Apache fails to be restarted?

1 Check port lsof-I: 80

2. Disable all programs that use port 80, as shown in figure

Kill-9 5031

Kill-9 5032

There may be more than one

3. Restart Apache.

Apache restart command:
/Usr/local/apache2/bin/apachectl restart

 

 

 

 

Linux kill usage, killall, pkill, xkill differences http://www.2cto.com/ OS /201202/118483.html

Basic operation method:
This document assumes that your apahce installation directory is/usr/local/apache2. These methods are suitable for any situation.

Apahce startup command:
Recommended/usr/local/apache2/bin/apachectl start apaceh startup

Apache Stop command
/Usr/local/apache2/bin/apachectl stop

Apache restart command:
/Usr/local/apache2/bin/apachectl restart

To restart the Apache server without interrupting the current connection, run:

/Usr/local/sbin/apachectl graceful

If Apache is installed as a Linux service, run the following command:

Service httpd start

Service httpd restart

Service httpd Stop Service

 

Linux is Ubuntu

1. Start Apache 2 server/start Apache service

#/Etc/init. d/apache2 start
Or
$ Sudo/etc/init. d/apache2 start

2. Restart Apache 2 server/restart apache service

#/Etc/init. d/apache2 restart
Or
$ Sudo/etc/init. d/apache2 restart

3. Stop Apache 2 server/Stop apache service

#/Etc/init. d/apache2 stop
Or
$ Sudo/etc/init. d/apache2 stop

 

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.