ubuntu 下的nginx服务器配置详解
作者:隔壁陈叔叔
这篇文章主要介绍了ubuntu 下的nginx服务器配置详解的相关资料,需要的朋友可以参考下
ubuntu 下的nginx服务器配置详解
1.nginx服务器的安装
sudo apt-get install nginx
2.nginx服务器的启动
sudo /etc/init.d/nginx start
3.多域名对应不同的后台服务器
在/etc/nginx/sites-enabled/ 目录中删除default配置文件
新建域名对应的配置文件
比如test.youlunshidai.com
#通过upstream nodejs__upstream 可以配置多台nodejs节点,做负载均衡 upstream nodejs__upstream__test__youlunshidai { server 127.0.0.1:8089; #服务器地址和端口号 #server 127.0.0.1:8088; #负载均衡服务器地址和端口号 keepalive 64; #设置存活时间。如果不设置可能会产生大量的timewait } server { listen 80; server_name test.youlunshidai.com; access_log /var/log/nginx/test_youlunshidai.log; #nginx日志文件 location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header Connection ""; proxy_http_version 1.1; proxy_pass http://nodejs__upstream__test__youlunshidai; #反向代理转发 http://nodejs__upstream; } }
如果还有其他域名和后台服务器,在目录下继续新建对应的域名配置文件即可
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
您可能感兴趣的文章:
- ubuntu16.04服务器配置ssh免密码登录
- Ubuntu服务器配置apache2.4的限速功能shell脚本分享
- ubuntu上配置Nginx+PHP5 FastCGI服务器配置
- 在Ubuntu Server 22.04上安装 Docker的详细步骤记录
- Ubuntu 22.04或20.04安装Oracle SQL Developer的图文教程
- Ubuntu22.04系统下升级nodejs到v18版本
- Ubuntu22.04使用nginx部署vue前端项目的详细教程
- Ubuntu22.04系统:fatal: 无法连接到 github.com
- Ubuntu 22.04.1 LTS 编译安装 nginx-1.22.1的配置过程
- ubuntu 22.04搭建OpenVPN服务器的详细图文教程
- ubuntu22.04将python源切换为清华源的方法
- ubuntu 22.04安装mysql 8.0步骤与避坑指南
- Ubuntu22.04 LTS 上安装Redis的过程
- ubuntu22.04 server安装及使用详细图文教程
- Ubuntu22.04安装PyTorch1.12.1 GPU版本全过程
- Virtualbox 下 Ubuntu 22.04 网络互通/固定IP 配置方法
- VMware 虚拟机图文安装和配置 Ubuntu Server 22.04 LTS 的详细步骤
- Ubuntu 22.04 服务器安装部署(nginx+postgresql)