Home Operation and Maintenance Nginx How to do reverse proxy in nginx

How to do reverse proxy in nginx

Jun 12, 2019 am 10:45 AM
nginx reverse proxy

How to do reverse proxy in nginx

How does nginx do a reverse proxy?


The network structure is as shown above.

Maybe you only have one public IP address. But you have a website on your intranet If you need to map to the external network and do not want to add other non-80 ports, you can directly use nginx as a reverse proxy.

First, configure the nginx.conf file.

http {
    include                 mime.types;
    default_type            application/octet-stream;
    client_max_body_size    8m;    ################################################################################
    include /usr/local/u-mail/config/nginx/reverse-proxy.conf;    ################################################################################
    #log_format             main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                             '$status $body_bytes_sent "$http_referer" '
    #                             '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log             logs/access.log  main;
    sendfile                on;    #tcp_nopush             on;
    #keepalive_timeout      0;
    keepalive_timeout       65;    #gzip                   on;    upload_progress         proxied 1m;    ###############################################################################    gzip             on;    #client_max_body_size    50m;    client_body_buffer_size 256k;
    client_header_timeout   3m;
    client_body_timeout     3m;
    send_timeout            3m;
    proxy_connect_timeout   300s;
    proxy_read_timeout      300s;
    proxy_buffer_size       64k;
    proxy_buffers  4        32k;
    proxy_busy_buffers_size 64k;
    proxy_temp_file_write_size        64k;
    proxy_ignore_client_abort        on;    
     
    ###############################################################################
    include                 vhost/*.conf;
}
Copy after login

The above configuration file refers to the /usr/local/u-mail/config/nginx/reverse-proxy.conf;

configuration file. You can use relative paths for this filling, or The absolute path can be filled in. For the sake of demonstration, the absolute path will be filled in directly.

Then look at the referenced configuration file information.


As above. Then restart the nginx service directly. Check whether it is normal and whether there is any error. If there is no error message, it is OK. If you have multiple websites, you can set multiple server sections in reverse-proxy.conf. .One website and one section. Separate them. It will be convenient to check next time.

For more Nginx related knowledge, please visit the Nginx Usage Tutorial column!

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

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

HTTP request sniffing defense method in Nginx reverse proxy HTTP request sniffing defense method in Nginx reverse proxy Jun 11, 2023 am 08:12 AM

HTTP request sniffing defense method in Nginx reverse proxy

Nginx reverse proxy Websocket configuration tutorial to achieve real-time communication Nginx reverse proxy Websocket configuration tutorial to achieve real-time communication Jul 04, 2023 pm 03:28 PM

Nginx reverse proxy Websocket configuration tutorial to achieve real-time communication

Nginx reverse proxy server connection limit and request queue tuning method Nginx reverse proxy server connection limit and request queue tuning method Aug 08, 2023 am 10:37 AM

Nginx reverse proxy server connection limit and request queue tuning method

Secure DNS resolution in Nginx reverse proxy Secure DNS resolution in Nginx reverse proxy Jun 11, 2023 am 09:51 AM

Secure DNS resolution in Nginx reverse proxy

Nginx reverse proxy HTTPS configuration, encrypted website transmission Nginx reverse proxy HTTPS configuration, encrypted website transmission Jul 04, 2023 pm 12:45 PM

Nginx reverse proxy HTTPS configuration, encrypted website transmission

Nginx reverse proxy WebSocket configuration to achieve real-time communication Nginx reverse proxy WebSocket configuration to achieve real-time communication Jul 04, 2023 pm 05:37 PM

Nginx reverse proxy WebSocket configuration to achieve real-time communication

Multi-port access control policy in Nginx reverse proxy Multi-port access control policy in Nginx reverse proxy Jun 10, 2023 pm 11:28 PM

Multi-port access control policy in Nginx reverse proxy

Security performance monitoring and analysis in Nginx reverse proxy Security performance monitoring and analysis in Nginx reverse proxy Jun 10, 2023 am 09:28 AM

Security performance monitoring and analysis in Nginx reverse proxy

See all articles