Nginx反向代理
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Nginx反向代理,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1908字,纯文字阅读大概需要3分钟。
内容图文
1、实验环境:
10.0.10.8 nginx反向代理
10.0.10.10 nginx节点
10.0.10.12 nginx节点
2、系统内核版本:
# cat /etc/redhat-release
CentOS release 6.6 (Final)
# uname -r
2.6.32-504.3.3.el6.x86_64
3、在nginx反向代理
# cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server_tokens off;
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 logs/access.log main;
upstream backend{
#ip_hash; #会话保持
server 10.0.10.12:80 weight=1;
server 10.0.10.10:80 weight=1;
}
server {
listen 80;
server_name www.cui.com;
location / {
proxy_pass http://backend;
proxy_set_header Host $host; #支持多个虚拟主机
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr; #这三个是使节点记录真实IP的
}
}
}
4、在nginx节点上
cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
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 logs/access.log main;
server {
listen 80;
server_name www.cui.com;
location / {
root /data/www;
index index.html index.htm;
}
}
}
5、浏览器访问
650) this.width=650;" src="/upload/getfiles/default/2022/11/10/20221110051341405.jpg" title="32BHR`3Y]P}%EXR)Y(TX1R5.png " />
本文出自 “肖海” 博客,请务必保留此出处http://eveday.blog.51cto.com/10577430/1684889
原文:http://eveday.blog.51cto.com/10577430/1684889
内容总结
以上是互联网集市为您收集整理的Nginx反向代理全部内容,希望文章能够帮你解决Nginx反向代理所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。