Linux中nginx.conf如何配置【搬代码】

Nginx 是一个独立的软件。

它是一款高性能的 Web 服务器、反向代理服务器和负载均衡器等,具有强大的功能和广泛的应用场景。它通常需要单独进行安装和配置来发挥其作用。

下载网址:http://nginx.org/en/download.html

nginx.conf写法:

java 复制代码
#配置权重
upstream byeng{
		server 192.168.31.25:8585 weight=1;
		server 192.168.31.25:8586 weight=1;
	}
upstream bya{
		server 192.168.31.25:8585 weight=1;
		server 192.168.31.25:8586 weight=1;
	}
server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
			#此处nginx是跳上面upstream byeng权重
			proxy_pass http://byeng; 
        }	


		#byeng后面加/,http后面有端口端口后面也要加/
		location /byeng/ {
			proxy_pass http://192.168.31.25:8585/;
		}
		#也可以这样写
		location /a/ {
			proxy_pass http://bya/; 
		}
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
java 复制代码
upstream bya{
		server 192.168.31.25:8585 weight=1;
		server 192.168.31.25:8586 weight=1;
	}
	
server{

 		listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }	
	#也可以这样写
		location /a/ {
			proxy_pass http://bya/; 
		}
}


其实Linux和window配置是一样的

相关推荐
print_Hyon2 分钟前
【ENSP】DHCP 基础实验(路由器作为 DHCP 服务器,接口地址池模式)
运维·服务器·智能路由器
程序员-Benothing11 分钟前
正则表达式详解:BRE、ERE、PCRE语法与实战案例
linux·运维·服务器
软件架构师-叶秋12 分钟前
V853方案之ubuntu开发环境搭建
linux·运维·服务器·全志·v853
yt004yt18 分钟前
园区绿岛 VOC 治理,能碳一体化系统设计思路分享
大数据·运维
lzx_00219 分钟前
Linux 开发工具(二) 简单认识一下编辑器 —— vim
linux·编辑器·vim
码士集团小青24 分钟前
美团Tabbit实测:免费用GPT-5.5和Claude Opus 4.8,浏览器Agent自动化到底能干什么
运维·gpt·自动化
AlfredZhao27 分钟前
堡垒机里 `su - oracle` 被拦截,怎么绕过限制切换用户
linux
zhangjw3432 分钟前
1-1 PostgreSQL 多平台环境部署:Linux|Docker|Windows|MacOS 完整实操
linux·docker·postgresql
流星白龙33 分钟前
【Docker】13.容器基本操作实战
运维·docker·容器
还卿一钵无情泪11 小时前
Unsloth 微调 构建自己的大模型 没有GPU也能微调
linux·开发语言·人工智能·python·大模型·nlp·unsloth