ubuntu 安装nginx

bash 复制代码
sudo apt-get update
sudo apt-get install nginx
sudo nginx -v


sudo systemctl status nginx
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx

#浏览器输入:http://192.168.31.181/


#查看文件结构
cd /etc/nginx
sudo cp nginx.conf nginx.conf-org

#添加一个站点代理
nano /etc/nginx/conf.d/api.demo.com.conf
====================
server {
    server_name   api.demo.com;
 
    location / {
        proxy_pass http://192.168.31.142:5001;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
    }
}
===========================

#host添加一段
192.168.31.181 api.demo.com

浏览器访问:

http://api.demo.com/swagger/index.html

相关推荐
喵了meme1 天前
Linux学习日记21:读写锁
linux·c语言·学习
LYFlied1 天前
TypeScript 常见面试问题
ubuntu·面试·typescript
暴躁的菜鸡1 天前
postgresql16.8二进制包编译
ubuntu·postgresql
^乘风破浪^1 天前
Ubuntu部署Xingrin(星环)企业级漏洞扫描与资产管理平台
linux·运维·ubuntu
Lueeee.1 天前
内核模块符号的导出
linux·运维·服务器
C语言魔术师1 天前
【linux】linux进程概念(四)(环境变量)
linux·运维·服务器
松涛和鸣1 天前
DAY32 Linux Thread Programming
linux·运维·数据库·算法·list
eggrall1 天前
《gdb 与 cgdb 深度解析:命令行调试的效率革命》
linux
晨曦夜月1 天前
头文件与目标文件的关系
linux·开发语言·c++
白仑色1 天前
java中的anyMatch和allMatch方法
java·linux·windows·anymatch·allmatch