current position:Home>Centos7 nginx reverse proxy TCP port

Centos7 nginx reverse proxy TCP port

2022-04-29 15:53:59Mischief 1124

1、 Check nginx

nginx -V

If there is... In the compilation parameters --with-stream, explain nginx The server has met the requirements

If you don't have , Refer to the installation method at the end of the article for installation

2、 modify nginx The configuration file

stay nginx.conf add ( and http At the same level ):

stream {
    upstream server-stream {
        server x.x.x.x:6443;
    server {
        listen 7443;
        proxy_connect_timeout 2s;
        proxy_timeout 900s;
        proxy_pass server-stream;

  • stream Reverse proxy module and http Is a peer , Don't write the configuration to http Inside
  • In profile upstream server-stream It is used for load balancing , Will choose the best server from different servers
  • proxy_pass Indicates forwarding the request to the server

 3、 test

nginx -t

problem 1:unknown directive "stream" in /etc/nginx/nginx.conf

terms of settlement :

# install nginx Source
curl -o /etc/yum.repos.d/epel.repo
# Install first
yum -y install epel-release

# It should be the lack of modules modular
yum -y install nginx-all-modules.noarch

copyright notice
author[Mischief 1124],Please bring the original link to reprint, thank you.

Random recommended