Nginx/apache Reverse Proxy

Source: Internet
Author: User

Original intention: Only one server on a 80 port, if you want to deploy multiple sets of sites, there will inevitably be www.veblen.com:80808080 or www.veblen.com/test/child/pro.html such embarrassing situation, anti-human operations .

Nginx
    • Download Nginx
    • Double-click the application to launch

N3.png
    • In the browser window, enter localhost to appear on the page, which is the agent success



      N2.png
    • Open Config folder under nginx.conf file

N1.png

Add under HTTP

server {    listen 80;    server_name www.veblen.com;    location / {        proxy_set_header   X-Real-IP $remote_addr;        proxy_set_header   Host      $http_host;        proxy_pass         http://127.0.0.1:8082;    }}

This way, when the www.veblen.com is accessed, it will be proxied to the http://127.0.0.1:8082 port.

Apache (using the Phpstudy tool)
    • Open vhost-conf File

A1.png
    • Add the following code to the file to point www.veblen.com to any file
<VirtualHost *:80>    DocumentRoot "E:\WWW/test/child/pro.html"    ServerName www.veblen.com    ServerAlias veblen.com  <Directory "E:\WWW/test/child/pro.html">      Options FollowSymLinks ExecCGI      AllowOverride All      Order allow,deny      Allow from all      Require all granted  </Directory></VirtualHost>
    • Proxy port, first introduced in Apache module

A2.png
    • vhost-confAdd the following code to the file to point the www.veblen.com to any port
<VirtualHost *:80>    ServerName www.veblen.com    <Proxy *>        Order deny,allow        Allow from all    </Proxy>ProxyPass / http://127.0.0.1:8080/ProxyPassReverse / http://127.0.0.1:8080/</VirtualHost>

Add: If students want to test locally, you can set up several intercept domain names

    • Locate the Hosts file

H1.png

Add the following content

127.0.0.1    www.veblen1.com127.0.0.1    www.veblen2.com

Nginx/apache Reverse Proxy

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.