Linux 常用工具
YUM
yum init system
create local repo yum
centos 7 init system
FTP
How to Install and Configure vsftpd on CentOS 6
vsftp install on centos 7
Email
aliyun ecs install email
postfix smtp on centos
centos 6 postfix smpt test
GIT
gogs install centos6
git command example
git format markdown
HTTP Web
apache exampe
h5ai web php file server
apache vhosgts code debug
Nginx Web
nginx install from source
nginx set directory autoindex
autoindex with h5ai web
nginx install pugin ngx-fancyindex
proxy internal vhost to web
dynamic and static by nginx
proxy directory second by nginx
nginx proxy gogs web
jenkns proxy from nginx
ssl certify by nginx
nginx threads fix to 9x
NTP
linux install ntp use asia date
VNC
vnc remote desktop
x11vnc on centos6
Firewall
iptables on centos 7
centos7 firewalld config
Kernel
centos kernel packages
kernel update to 3.10 on centos 6
SYSCTL 内核配置参数分析
NFS
centos6 install nfs servers
mount nfs to linux
mount nfs on centos 6
centos6 nfs verify permissions
SSH
ssh keygen rsa to client
ssh config diffent
Network
centos 7 config net-tool debug ifconfig
debug network card up or down
Samba
samba install on centos 6
samba config example
VIM
VIM using example
本文档使用 MrDoc 发布
-
+
首页
dynamic and static by nginx
# dynamic and static by nginx --- ## 使用nginx作为代理实现动静分离 ## 目标: 1. 客户端访问http://www.jbboo.com => 解析到 nginx_proxy 192.168.1.6 2. nginx proxy => 解析到 squid 1 / squid 2 3. nginx proxy => 解析到 lamp 1 / lamp 2 IP部署 - nginx proxy - 192.168.1.6 www.jbboo.com - squid A B - 192.168.1.4 ; 192.168.1.5 squ.jbboo.com sqb.jbboo.com - lamp/lnmp A B - 192.168.1.2 ; 192.168.1.3 mpa.jbboo.com mpb.jbboo.com ## 配置nginx_proxy YUM 软件安装说明 # yum install pcre pcre-devel -y # yum install nginx nginx-devel -y # /etc/init.d/nginx start # vim /etc/nginx/nginx.conf 需要改动的地方在 HTTP 模块 内,增加 upstream 访问 squid 和 lamp ```http # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes 1; error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; 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 0; keepalive_timeout 65; upstream squid.jbboo.com { # server squid_1 ip 192.168.1.4 server 192.168.1.4 max_fails=5 fail_timeout=30s; # server 192.168.1.4 weight=1 max_fails=3 fail_timeout=15s; # server squid_2 ip 192.168.1.5 # server 192.168.1.5 weight=1 max_fails=3 fail_timeout=15s; server 192.168.1.5 max_fails=5 fail_timeout=30s; # weight=1 } upstream lnmp.jbboo.com { # ip_hash; # server lnmp_1 ip 192.168.1.2 server 192.168.1.2 max_fails=5 fail_timeout=30s; # server 192.168.1.2 weight=1 max_fails=3 fail_timeout=15s; # server lnmp_2 ip 192.168.1.3 server 192.168.1.3 max_fails=5 fail_timeout=30s; # server 192.168.1.3 weight=1 max_fails=3 fail_timeout=15s; server 127.0.0.1:8080 backup; } #gzip on; # Load config files from the /etc/nginx/conf.d directory # The default server is in conf.d/default.conf include /etc/nginx/conf.d/*.conf; } # vim /etc/nginx/conf.d/www.jbboo.com.conf # ###################################################################################### server { listen 80; server_name www.jbboo.com jbboo.com; # ########## ########## ########## ########## # add_header X-Via $server_addr; # add_header X-Cache $upstream_cache_status; # ########## ########## ########## ########## location ~* \.(gif|bmp|jpeg|jpg|png|css|js|html|htm|txt)$ { proxy_pass http://squid.jbboo.com; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; } # location / { proxy_pass http://lnmp.jbboo.com; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; } } # ###################################################################################### ``` 如果 squid服务器和 lamp 服务器不能提供服务,就显示主页在维护。 # mkdir /var/www/html/errpage # echo "this server was PM plan." >> /var/www/html/errpage/index.html # chown www:www /var/www/html/errpage/index.html ```http ###################################################################################### server { listen 8080; server_name localhost; charset utf-8; #access_log logs/host.access.log main; location / { root /var/www/html/errpage; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } # ###################################################################################### ``` ## 部署lnmp节点 LAMP 安装方法这里请参考地址 LAMP + 192.168.1.2 ; 192.168.1.3 部署squid YUM 软件安装说明 # yum install squid -y # chkconfig squid on # /etc/init.d/squid start + IP: 192.168.1.4 ; 192.168.1.5 ```http acl manager proto cache_object acl localhost src 127.0.0.1/32 ::1 acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1 acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12 # RFC1918 possible internal network acl localnet src 192.168.0.0/16 # RFC1918 possible internal network acl localnet src fc00::/7 # RFC 4193 local private network range acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines acl SSL_ports port 443 acl Safe_ports port 80 8080 # http acl Safe_ports port 81 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT http_access allow manager localhost http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow localnet http_access allow localhost http_access allow all # 把原来的deny all 修改成 allow all http_port 80 accel vhost vport # 修改监听端口的参数,并且设定模式为加速模式 icp_port 3130 cache_peer 192.168.1.2 parent 80 0 originserver name=lamp1 cache_peer 192.168.1.3 parent 80 0 originserver name=lamp2 # 定义 192.168.1.2 为父节点,他是原始节点,squid没有的,不能处理的请求都去问lamp cache_peer_domain lamp1 www.jbboo.com cache_peer_domain lamp2 www.jbboo.com # 如果squid接受到的客户端访问的请求是www.jbboo.com,这些请求都应该和lamp1/lamp2节点关联系 cache_peer 104.224.169.66 sibling 80 3130 # 邻居 两个服务器设置对方的 IP visible_hostname squ.jbboo.com cache_dir ufs /var/spool/squid 204800 16 256 cache_mem 256 MB maximum_object_size_in_memory 2048 KB maximum_object_size 102400 KB logformat combined %{X-Real-IP}>h %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh access_log /var/log/squid/access.log combined coredump_dir /var/spool/squid refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320 ``` cache_mgr jbboo@126.com # squid -k parse # squid -z # /etc/init.d/squid restart # ll /var/spool/squid ## 测试 客户端把www.jbboo.com解析的IP绑定到 192.168.1.6
Bobby
2021年12月20日 23:19
分享文档
收藏文档
阅读
146
上一篇
下一篇
微信扫一扫
复制链接
手机扫一扫进行分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码