搭建Nginx七层反向代理

基于https://www.cnblogs.com/Dfengshuo/p/11911406.html这个基础上,在来补充下七层代理的配置方式。简单理解下四层和七层协议负载的区别吧,四层是网络层,负载方式也就是IP+端口的方式负载,七层(应用层)协议的负载方式就是通过URL的方式来进行负载。这就是一个简单通俗的理解吧。

nginx安装方式再讲四层的时候已经说过了,这里就不再继续安装了。就直接上配置文件了

搭建Nginx七层反向代理
1 #user  nobody;
  2 worker_processes  1;
  3
  4 #error_log  logs/error.log;
  5 #error_log  logs/error.log  notice;
  6 #error_log  logs/error.log  info;
  7 #pid        logs/nginx.pid;
  8 events {
  9     worker_connections  1024;
 10 }
 11
 12 http {
 13     include       mime.types;
 14     default_type  application/octet-stream;
 15     #access_log  logs/access.log  main;
 16     sendfile        on;
 17     #tcp_nopush     on;
 18     #keepalive_timeout  0;
 19     keepalive_timeout  65;
 20     #gzip  on;
 21     server {
 22         listen       80;       #代理端口
 23         server_name  10.156.128.251;    #代理名称
 24         large_client_header_buffers 4 128k;
 25         client_max_body_size 300m;
 26         client_body_buffer_size 128k;
 27         proxy_connect_timeout 600;
 28         proxy_read_timeout 600;
 29         proxy_send_timeout 600;
 30         proxy_buffer_size 64k;
 31         proxy_buffers   4 32k;
 32         proxy_busy_buffers_size 64k;
 33         proxy_temp_file_write_size 64k;
 34         #charset koi8-r;
 35         #access_log  logs/host.access.log  main;
 36         location / {
 37           # root   html;
 38             index  index.html index.htm;
 39             proxy_pass   http://10.156.128.201/;       #要跳转server的IP
 40             proxy_set_header X-Real-IP $remote_addr;
 41             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 42             proxy_set_header Host $host:$server_port;
 43
 44
 45         }
 46
 47         #error_page  404              /404.html;
 48
 49         # redirect server error pages to the static page /50x.html
 50         #
 51         error_page   500 502 503 504  /50x.html;
 52         location = /50x.html {
 53             root   html;
 54         }
 55
 56         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
 57         #
 58         #location ~ \.php$ {
 59         #    proxy_pass   http://127.0.0.1;
 60         #}
 61
 62         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 63         #
 64         #location ~ \.php$ {
 65         #    root           html;
 66         #    fastcgi_pass   127.0.0.1:9000;
 67         #    fastcgi_index  index.php;
 68         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
 69         #    include        fastcgi_params;
 70         #}
 71
 72         # deny access to .htaccess files, if Apache's document root
 73         # concurs with nginx's one
 74         #
 75         #location ~ /\.ht {
 76         #    deny  all;
 77         #}
 78     }
 79
 80
 81     # another virtual host using mix of IP-, name-, and port-based configuration
 82     #
 83     #server {
 84     #    listen       8000;
 85     #    listen       somename:8080;
 86     #    server_name  somename  alias  another.alias;
 87
 88     #    location / {
 89     #        root   html;
 90     #        index  index.html index.htm;
 91     #    }
 92     #}
 93
 94
 95     # HTTPS server
 96     #
 97     #server {
 98     #    listen       443 ssl;
 99     #    server_name  localhost;
100
101     #    ssl_certificate      cert.pem;
102     #    ssl_certificate_key  cert.key;
103
104     #    ssl_session_cache    shared:SSL:1m;
105     #    ssl_session_timeout  5m;
106
107     #    ssl_ciphers  HIGH:!aNULL:!MD5;
108     #    ssl_prefer_server_ciphers  on;
109
110     #    location / {
111     #        root   html;
112     #        index  index.html index.htm;
113     #    }
114     #}
115
116 }

View Code

当然,笔者这份配置文件没有进行优化,只是实现了代理效果,自己也可以根据需求进行优化

  • 但行好事, 莫问前程 –

Original: https://www.cnblogs.com/Dfengshuo/p/11911786.html
Author: fs_Dong
Title: 搭建Nginx七层反向代理

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/585725/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • [ Skill ] 文件读写 & IO 句柄

    在 Skill 中使用一种叫做 ioport 类型的变量来操作文件。不过我一般更习惯称为 IO 句柄 (IO/File Handle)。 常用下面两个函数来获得这些 IO 句柄: …

    Linux 2023年6月7日
    0101
  • 正则表达式测试

    本博客所有文章仅用于学习、研究和交流目的,欢迎非商业性质转载。 博主的文章没有高度、深度和广度,只是凑字数。由于博主的水平不高,不足和错误之处在所难免,希望大家能够批评指出。 博主…

    Linux 2023年6月13日
    090
  • 0. 西门子 WinCC 组态软件 — 概述

    西门子 WinCC 组态软件 — 概述 1.西门子WinCC各产品线及定位 WinCC是由SIEMENS(西门子)公司开发的SCADA(数据采集与监控)系统,能高效控制…

    Linux 2023年6月7日
    093
  • 数据库事务的四大特性(ACID)

    什么是数据库事务? 事务,就是一系列操作的整体,其结果就是这一系列操作要么全部成功,要么全部失败。 譬如说,一个经典的例子–转账。A要转帐给B 100块钱,要经历以下步…

    Linux 2023年6月6日
    098
  • SQLI-LABS(Less-1)

    Less-1(GET-Error-Single quotes-String) 打开Less-1页面,可以看到页面中间有一句 Please input the ID as param…

    Linux 2023年6月6日
    086
  • 在linux中使用tcpdump抓包的方法:

    在linux中使用tcpdump抓包的方法: 1,运行下面命令来从所有网卡中捕获数据包: tcpdump -i any 2,从指定网卡中捕获数据包 tcpdump -i eth0 …

    Linux 2023年5月27日
    0123
  • 【5】2022年7月

    7月3日 总结3号的一天就是只有一句话,”自己经历了什么只有自己最清楚,不要辜负自己经历的”。 7月3号凌晨2点,收拾好行李和整理房间,在网上购买日常用品到…

    Linux 2023年6月13日
    087
  • 06-MyBatis中ResultType和ResultMap的区别

    MyBatis中ResultType和ResultMap的区别 如果数据库结果集中的列名和要封装的属性名完全一致的话用 resultType属性 如果数据库结果集中的列名和要封装实…

    Linux 2023年6月7日
    0106
  • WPF 调试依赖属性变更方法

    本文告诉大家如何调试 WPF 的某个依赖属性被变更的方法 在 WPF 里面,所有的依赖属性都有带通知的功能,通过带通知的功能,可以在通知里加上断点,通过调用堆栈了解是哪个模块调用的…

    Linux 2023年6月6日
    098
  • 【设计模式】Java设计模式-单例模式

    【设计模式】Java设计模式 – 单例模式 😄 不断学习才是王道🔥 继续踏上学习之路,学之分享笔记👊 总有一天我也能像各位大佬一样🌝分享学习心得,欢迎指正,大家一起学习…

    Linux 2023年6月6日
    0159
  • VSCODE 配置远程调试环境

    以下内容为本人的著作,如需要转载,请声明原文链接微信公众号「englyf」 https://mp.weixin.qq.com/s/f1KZOlL92ojes-r2l9rlCw 我的…

    Linux 2023年6月6日
    0149
  • 操作系统实现-loader

    博客网址:www.shicoder.top微信:18223081347欢迎加群聊天 :452380935 大家好呀,终于我们到了操作系统的loader部分了,loader也是操作系…

    Linux 2023年6月13日
    075
  • shell升级

    对/sbin/nologin的理解 系统账号的shell使用 /sbin/nologin ,此时无法登陆系统,即使给了密码也不行。 所谓”无法登陆”指的仅是…

    Linux 2023年5月28日
    0108
  • windows环境安装VNC及远程连接linux(centos7)

    基础环境: 客户端:windows 10 服务器:centos7 软件:windows客户端安装 VNC-Viewer-6.21.1109-Windows.exe 下载地址:htt…

    Linux 2023年5月27日
    095
  • [转帖]shell 学习之正则、别名以及管道重定向

    404. 抱歉,您访问的资源不存在。 可能是网址有误,或者对应的内容被删除,或者处于私有状态。 代码改变世界,联系邮箱 contact@cnblogs.com 园子的商业化努力-困…

    Linux 2023年5月28日
    0100
  • 文件批量改名(有规律)

    1.如你的文件放在桌面名字为file的文件内,我要把这些文件批量名称改为page1.jpg,page2.jpg,page3.jpg………. 2….

    Linux 2023年6月13日
    091
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球