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

相关推荐
ai小陈8 小时前
GPU服务器租用存储验收:检查点写入与磁盘吞吐实战
运维·服务器·人工智能·ai·ssh·gpu算力
有毒的教程10 小时前
VMware仅主机模式:物理机 ↔ 虚拟机 文件共享
运维
山岚的运维笔记12 小时前
ComfyUI NVIDIA安装教程:官方便携版下载+run_nvidia_gpu.bat启动,8G显存Windows实操
运维·服务器·windows·笔记·prompt·aigc·comfyui
海宇大数据13 小时前
零信任架构实战:基于海宇活体识别V步骤1构建自动化远程公证会话初始化网关
运维·人工智能·架构·自动化
lisanmengmeng13 小时前
Nagios邮件报警的配置
linux·运维·服务器
Ruiery14 小时前
Linux 6.6内核 CPU 深度解析(六):cpufreq
linux·运维·服务器
天远数科14 小时前
零信任架构实战:基于天远全能消金报告构建自动化消费分期网关
运维·人工智能·架构·自动化
硅基手札15 小时前
【linux内核专栏 08】时间与定时器
linux·运维·服务器
想做小南娘,发现自己是女生喵15 小时前
Linux之Ubuntu入门篇知识总结
linux·运维·服务器
life码农15 小时前
Nginx 配置允许指定 IP 段访问:从 192.168.1.1 到 192.168.1.124 及 /24 详解
网络·tcp/ip·nginx