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

相关推荐
zjj587几秒前
ubuntu虚拟内存
linux·运维·ubuntu
Q688238861 分钟前
基于Matlab的LMI矩阵理论算法与矩阵不等式研究:待求矩阵在LMI区域内的优化设计与区间观...
ubuntu
终端行者1 小时前
Nginx 配置Websocket代理 Nginx 代理 Websocket
运维·websocket·nginx
*翊墨*1 小时前
达梦数据库Linux安装
linux·数据库·excel
瑶总迷弟1 小时前
在centos上基于kubeadm部署单master的k8s集群
linux·kubernetes·centos
是小胡嘛1 小时前
华为云CentOS系统中运行http服务器无响应
linux·服务器·c++·http·centos·华为云
lhyzws2 小时前
CENTOS上的网络安全工具(二十九)GPU助力SPARK
linux·spark·gpu算力
学嵌入式的长路2 小时前
正点原子imx6ull移植lvgl v8.3及触摸屏调试
linux·驱动开发·lvgl·imx6ull·触摸屏
馨谙2 小时前
使用 systemd 单元管理容器环境完全指南
linux
石像鬼₧魂石2 小时前
有哪些常见的字典可以用于Hydra的密码破解?
linux·学习·ssh