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

相关推荐
煜36419 分钟前
Linux初识与基本指令
linux·运维·服务器
执笔论英雄20 分钟前
【大模型推理】cudastream 学习
linux·运维·学习
shada27 分钟前
在Linux x86_64系统中编译mission
linux
佑白雪乐29 分钟前
<Linux基础第14集>总结前面知识点,不含Linux命令
linux·运维·服务器
YLXA33 分钟前
1.helle_cuda学习
linux·学习·算法
Lau_way1 小时前
windows通过xshell局域网连接linux
linux·运维·服务器
ken22321 小时前
(a-) 在不同软件包里:相同名称和用途的软件工具,功能不完全一样 + 查询网络路径中的最小 MTU 值工具 (***)
linux·运维·服务器
shamalee1 小时前
Nginx反向代理出现502 Bad Gateway问题的解决方案
运维·nginx·gateway
tjuarch1 小时前
技术备忘录:华硕 A43S (Ubuntu) 插电限频故障修复
linux·chrome·ubuntu·技术备忘录
爱莉希雅&&&1 小时前
haproxy安装以及haproxy+nginx简单案例详解
linux·运维·nginx·haproxy