Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of apache configuration Virtual Host and reverse proxy in ubuntu system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you the ubuntu system apache configuration of virtual hosts and reverse proxy example analysis, I hope you will learn something after reading this article, let's discuss it together!

Configure virtual host

$sudo vi / etc/apache2/sites-available/000-default.conf#DocumentRoot / var/www/html # # comment out the line $cat / etc/apache2/sites-available/000-default.conf | grep-v "#" ServerAdmin webmaster@localhost ServerName www.blogsir.com.cn DocumentRoot "/ var/www/html/" ErrorLog ${APACHE_LOG_DIR} / error.log CustomLog ${APACHE_LOG_DIR} / access.log combined ServerName www.s7star.cn DocumentRoot "/ var/ Www/xx "ErrorLog ${APACHE_LOG_DIR} / error.log CustomLog ${APACHE_LOG_DIR} / access.log combined

Note 1: here * refers to 127.0.01

Modify the host file and add the following

$sudo vi / etc/hosts127.0.0.1 www.blogsir.com.cn127.0.0.1 www.s7star.cn

Configure port reverse proxy

If the port is not 80, you can configure a reverse proxy. For example, my ctf.s7star.cn is accessed through port 4000 at first, but it is not very convenient. It is much more convenient after configuring the reverse proxy.

The interpretation on the reverse proxy wiki goes like this: it fetches resources from the back-end server at the client's request, and then returns those resources to the client. Unlike the forward proxy, the forward proxy acts as a medium to return the resources acquired on the Internet to the associated client, while the reverse proxy is used as a proxy on the server side, not the client side.

The port of the blog uses 4000. After using the reverse proxy, the user returns to the website at port 80, and apache will display the content of the blog to the user, just as the user accesses port 4000 directly.

Here are the steps to configure apache:

1. Load the apache module and load the module using the a2enmod command

A2enmod proxy proxy_balancer proxy_http

After loading, you need to restart the server using command / etc/init.d/apache2 restart

two。 Configure the reverse proxy function, enter sites_available, edit the 000-default.conf file, and add the following code

ServerName ctf.s7star.cn DocumentRoot "/ var/www/xx/" ErrorLog ${APACHE_LOG_DIR} / ctf_errors.log CustomLog ${APACHE_LOG_DIR} / ctf_accesses.log combined ProxyPass / http://127.0.0.1:4000/ ProxyPassReverse / http://127.0.0.1:4000/

Finally, restart apache, and when you reopen the web page, you will jump to the blog on port 4000.

After reading this article, I believe you have a certain understanding of "sample analysis of apache configuration virtual host and reverse proxy under ubuntu system". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report