日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Nginx —— 用HTTP proxy module配置一个反向代理服务器

發布時間:2025/10/17 75 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nginx —— 用HTTP proxy module配置一个反向代理服务器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

反響代理(reverse proxy)方式是指用代理服務器來接受Internet上的連接請求,然后將請求轉發給內部網絡中的上游服務器,并將從上游服務器上得到的結果返回給Internet上請求連接的客戶端,此時代理服務器對外的表現就是一個Web服務器。充當反響代理服務器也是nginx的一種常見的用法(反響代理服務器必須能夠大量處理并發請求)。

1》上游服務器地址 : 192.168.1.60

2》上游服務器被訪問文件:

[root@localhost html]# ip addr | grep 192inet 192.168.1.60/24 brd 192.168.1.255 scope global noprefixroute eno1inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0inet 192.168.135.1/24 brd 192.168.135.255 scope global vmnet8 [root@localhost html]# [root@localhost html]# pwd /var/www/html [root@localhost html]# cat index.html <html> <h1>This is 192.168.1.60!</h1> </html>

3》代理服務器地址: 192.168.1.210

4》 代理服務器配置conf:

[root@localhost conf]# cat nginx.conf | grep -v "#" worker_processes 1;events {worker_connections 1024; }http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server {listen 8080;server_name localhost;location / {proxy_pass http://192.168.1.60;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}} }

5》啟動nginx服務器(找到nginx的二進制文件):

[root@localhost conf]# /usr/local/nginx/sbin/nginx

6》客戶端測試地址: 192.168.1.93

打瀏覽器地址欄輸入: http://192.168.1.210:8080/

注意: 這里一定要加conf文件中監聽的端口,否則http默認監聽80端口。

頁面顯示內容:

[root@localhost html]# cat index.html <html> <h1>This is 192.168.1.60!</h1> </html>

7》測試中出現的問題:

<1>測試頁面出現:An error occurred.

An error occurred.Sorry, the page you are looking for is currently unavailable. Please try again later.If you are the system administrator of this resource then you should check the error log for details.Faithfully yours, nginx.

解決方式:在1.60上執行命令,開啟httpd服務

[root@localhost html]# service httpd start

?

注意:? Nginx —— nginx服務的基本配置(nginx.conf文件的詳解)

總結

以上是生活随笔為你收集整理的Nginx —— 用HTTP proxy module配置一个反向代理服务器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。