nginx http反向代理

系统:Ubuntu_24.0.4

1、安装nginx

sudo apt-get update

sudo apt-get install nginx

sudo systemctl start nginx

2、配置nginx.conf文件

/etc/nginx/nginx.conf,但可以在 /etc/nginx/sites-available/ 目录下创建一个新的配置文件,并在 /etc/nginx/sites-enabled/ 目录下创建一个指向它的符号链接。

vim /etc/nginx/nginx.conf

复制代码
        server {
            listen 80;
            server_name 192.168.0.32;  # 替换为你的域名或服务器 IP

            location /Firework_Simulator/ {
                proxy_pass http://192.168.0.188:8089;  # 替换为你的后端服务器地址
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
            }
        }

server_name 设置为nginx服务器IP地址或者映射域名

location 请求的方式

proxy_pass 你需代理的服务器地址

3、启动或重新加载nginx

sudo nginx -t

sudo systemctl reload nginx

验证命令

curl -I

相关推荐
yuanManGan7 分钟前
走进Linux的世界:初识操作系统(Operator System)
android·linux·运维
i_am_a_div_日积月累_26 分钟前
jenkins打包报错
运维·rust·jenkins·jenkins打包报错
GIOTTO情33 分钟前
舆情处置的自动化实践:基于Infoseek舆情系统的技术解析与落地指南
运维·自动化·linq
Thexhy37 分钟前
在 CentOS 7 的 Linux 系统中配置 NFS
linux·运维·学习·centos
曹天骄1 小时前
Let’s Encrypt 证书申请与多服务器 HTTPS 配置指南
运维·服务器·https
lang201509281 小时前
如何在 Linux 中获取更多信息
linux·运维·服务器
DeBuggggggg1 小时前
linux 安装Python3.9 且支持SSL
linux·运维·ssl
我是标同学1 小时前
vmware17安装ubuntu2204版本qemu运行armv8处理器uboot运行调试(包括windows)的一些工作
linux·运维·服务器
杨云龙UP1 小时前
【MySQL迁移】MySQL数据库迁移实战(利用mysqldump从Windows 5.7迁至Linux 8.0)
linux·运维·数据库·mysql·mssql
Wang's Blog1 小时前
Nestjs框架: 微服务断路器实现原理与OPOSSUM库实践
运维·微服务·nestjs