Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to set up a proxy server in nginx

Shulou Source: shulou.com Published: 2022-06-01 23:03:21 10月28日 Update

How to set up a proxy server in nginx? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

Step 1: start nginx

[root@devops] # docker run-p 8888 nginxc7baab8ea9da0a148aa9bcc1295a54391906f6be94efca7189df23ceecdbf714 8888-- name proxy-nginx-d nginxc7baab8ea9da0a148aa9bcc1295a54391906f6be94efca7189df23ceecdbf714 [root@devops] #

Step 2: setting nginx

Enter the container

[root@devops ~] # docker exec-it proxy-nginx sh

Update apt-get

Install ping/vi/ps:apt-get update; apt-get install procps vim inetutils-ping

Set nginx.conf

Add the following to achieve the simplest proxy function

Resolver 8.8.8.8; server {listen 8888; location / {proxy_pass http://$http_host$request_uri;}}

The rest of the information is confirmed by nginx.conf and has not been modified

# cat nginx.confuser nginx;worker_processes 1 error error log / var/log/nginx/error.log warn;pid / var/run/nginx.pid;events {worker_connections 1024;} http {include / etc/nginx/mime.types; default_type application/octet-stream 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 / var/log/nginx/access.log main; sendfile on; # tcp_nopush on; keepalive_timeout 65; # gzip on; resolver 8.8.8.8; server {listen 8888 Location / {proxy_pass http://$http_host$request_uri;}} include / etc/nginx/conf.d/*.conf;} #

Step 4: setting the client

Set the server IP and port 8888 above on the client side to connect to the network by changing the proxy server.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Server agent service content client client help central clear information function container this article novice more knowledge port network industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info macOS Apple Shulou Information MariaDB