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

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

 #user  nobody;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections ;
} http {
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout ;
keepalive_timeout ;
#gzip on;
server {
listen ; #代理端口
server_name 10.156.128.251; #代理名称
large_client_header_buffers 128k;
client_max_body_size 300m;
client_body_buffer_size 128k;
proxy_connect_timeout ;
proxy_read_timeout ;
proxy_send_timeout ;
proxy_buffer_size 64k;
proxy_buffers 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# root html;
index index.html index.htm;
proxy_pass http://10.156.128.201/; #要跳转server的IP
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port; } #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen ;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }

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

最新文章

  1. 【转】async & await 的前世今生
  2. three.js贴图
  3. Boost配置
  4. ubuntu安装jdk遇到的问题:cannot execute binary file
  5. java提高篇---HashTable
  6. id to load is required for loading----id被要求加载exception
  7. ProgressBar及其子类
  8. 关于getpw系列函数返回的静态区域
  9. ganglia的yum插件的配置
  10. 2.Hashing
  11. QT文件夹定位(网友提供)
  12. 使用 Visual Studio 对exe文件进行数字签名
  13. js注入 mooc
  14. 新建maven项目,JRE System Library[J2SE-1.5]
  15. Python(一)缺点
  16. python(leetcode)-66加一问题
  17. Python全栈开发之路 【第十七篇】:jQuery的位置属性、事件及案例
  18. Centos Firefox中文乱码
  19. ECMAscript5 新增数组内函数
  20. scala中隐式转换之总结

热门文章

  1. 利用WinRM实现内网无文件攻击反弹shell
  2. gitlab 提交
  3. UNCTF杂项题Hidden secret 之NTFS交换数据流隐写
  4. collectionView reloadData走了不执行cellForItemAtIndexPath
  5. 百万年薪python之路 -- 函数初始练习
  6. Nmap渗透测试使用方法
  7. fenby C语言 P9
  8. SpringBoot系列之@Value和@ConfigurationProperties
  9. Flink 从 0 到 1 学习 —— Flink Data transformation(转换)
  10. Hibernate---快速入门