Home  >  Article  >  Operation and Maintenance  >  How to configure nginx reverse proxy

How to configure nginx reverse proxy

(*-*)浩
(*-*)浩Original
2019-06-06 13:10:2530337browse

Nginx reverse proxy instructions do not need to add additional modules. The default proxy_pass instruction comes with it. You only need to modify the configuration file to implement reverse proxy.

How to configure nginx reverse proxy

Preparation work before configuration, the backend runs the IP and port of the apache service, which means that you can be accessed through http://ip:port website.

Then you can create a new redis.conf and add the following content. Remember to change the ip and domain name to your own.

The directory structure is as follows

├── nginx.conf
└── redis.conf

Modify the nginx.conf main configuration file, Add include redis.conf to the http{} section and reload nginx. The

redis.conf file is as follows:

## Basic reverse proxy server ##
## Apache backend for www.redis.com.cn ##
upstream apachephp  {
    server ip:8080; #Apache
}

## Start www.redis.com.cn ##
server {
    listen 80;
    server_name  www.redis.com.cn;

    access_log  logs/redis.access.log  main;
    error_log  logs/redis.error.log;
    root   html;
    index  index.html index.htm index.php;

    ## send request back to apache ##
    location / {
        proxy_pass  http://apachephp;

        #Proxy Settings
        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;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_max_temp_file_size 0;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
   }
}
## End www.redis.com.cn ##

For more Nginx related technical articles, please visit the Nginx Usage Tutorial column to learn!

The above is the detailed content of How to configure nginx reverse proxy. For more information, please follow other related articles on the PHP Chinese website!

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