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

相关推荐
bohu832 小时前
亚博microros小车-原生ubuntu支持系列:16 机器人状态估计
ubuntu·机器人·imu·localization·microros·imu_tools
深度Linux4 小时前
Linux网络编程中的零拷贝:提升性能的秘密武器
linux·linux内核·零拷贝技术
千夜啊5 小时前
Nginx 运维开发高频面试题详解
运维·nginx·运维开发
chian-ocean8 小时前
从理论到实践:Linux 进程替换与 exec 系列函数
linux·运维·服务器
拎得清n8 小时前
UDP编程
linux
敖行客 Allthinker8 小时前
从 UTC 日期时间字符串获取 Unix 时间戳:C 和 C++ 中的挑战与解决方案
linux·运维·服务器·c++
夏尔Gaesar10 小时前
Vim安装与配置教程(解决软件包Vim没有安装可候选)
linux·编辑器·vim
hunter20620610 小时前
如何监控ubuntu系统某个程序的运行状态,如果程序出现异常,对其自动重启。
linux·chrome·ubuntu
慕雪华年11 小时前
【Linux】opencv在arm64上提示找不到libjasper-dev
linux·运维·opencv
s_little_monster13 小时前
【Linux】从硬件到软件了解进程
linux·运维·服务器·经验分享·笔记·学习·学习方法