Ubuntu nginx各种代理及配置

Ubuntu nginx各种代理及配置一、nginx 反向代理单台服务器root@linux:/apps/nginx/conf.d# cat test.conf server{ server_name www.haha.com; listen 80; access_log /apps/nginx/logs/haha_access.log; error_log /app...
摘要由CSDN通过智能技术生成

Ubuntu nginx各种代理及配置

一、nginx 反向代理单台服务器
root@linux:/apps/nginx/conf.d# cat test.conf 
server{
	server_name www.haha.com;
	listen	80;
	access_log /apps/nginx/logs/haha_access.log;
        error_log  /apps/nginx/logs/haha_error.log;
        error_page  404              /no.html;
	server_tokens off;
	location /no.html {
		root /data/html;
	}
	location / {
		proxy_pass http://192.168.66.33;	
	}	 

}
root@linux:/apps/nginx/conf.d# 
root@linux:/apps/nginx/conf.d# nginx -s reload
root@linux:/apps/nginx/conf.d# curl 192.168.66.30
192.168.66.33 nginx
二、nginx 反向代理部分目录
root@linux:/apps/nginx/conf.d# cat test.conf 
server{
	server_name www.haha.com;
	listen	80;
	access_log /apps/nginx/logs/haha_access.log;
        error_log  /apps/nginx/logs/haha_error.log;
        error_page  404              /no.html;
	server_tokens off;
	location /no.html {
		root /data/html;
	}
	location / {
		proxy_pass http://192.168.66.33;	
	}	 
	location /web {
		proxy_pass http://192.168.66.32/;
	}

}
root@linux:/apps/nginx/conf.d# 
root@linux:/apps/nginx/conf.d# nginx -s reload
root@linux:/apps/nginx/conf.d# curl 192.168.66.30/web/
192.168.66.32  apache
root@linux:/apps/nginx/conf.d# curl 192.168.66.30
192.168.66.33 nginx
root@linux:/apps/nginx/conf.d#

# 后端服务器必须要有相应的web路径
root@linux:/var/www/html# mkdir web
root@linux:/var/www/html# cp index.html web/.
三、nginx 缓存功能

在http代码块中,定义缓存信息,注意这是一行

proxy_cache_path /data/nginx/proxy_cache #定义缓存保存路径,proxy_cache会自动创建
level
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值