Home >Backend Development >PHP Tutorial >Configure a simple nginx reverse proxy

Configure a simple nginx reverse proxy

WBOY
WBOYOriginal
2016-08-08 09:23:291037browse

I am reading the source code of ngx_http_upstream_module recently. First, let the module run, and then debug and trace. Here is an introduction to the nginx reverse proxy with simple configuration.

1. Install httpd

yum install httpd

echo "hello world!" > /var/www/html/index.html

service httpd start

After completing the above steps, you can test it: curl http://127.0.0.1

2. Modify nginx configuration file nginx.conf

server {

Listen 8080; #Because httpd has occupied port 80

location / {

proxy_pass http://127.0.0.1:80;

}

}

3. Test

At this point, nginx’s reverse proxy and upstream modules are ready to run. The test is as follows:

curl http://127.0.0.1:8080

The above introduces the nginx reverse proxy with simple configuration, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn