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
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)
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
H1.png
Add the following content
127.0.0.1 www.veblen1.com127.0.0.1 www.veblen2.com
Nginx/apache Reverse Proxy