服务器 Nginx 端口映射

查看了一些网上的资料,配置信息是错误的,常见于server_name;

// 参考链接

https://blog.csdn.net/weixin_43651277/article/details/107060581

 

 //   etc/nginx/nginx.conf 添加端口映射

server{

  //监听端口
  listen 80;

  //匹配解析域名,对应的请求域名,www 规则。*代表域名后缀
  server_name www.baidu.*;(baidu代指你自己的域名)
  location /{
    proxy_set_header Host $host:$server_port;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://localhost:9091/;

  //timeout 配置
    proxy_connect_timeout 60;

    proxy_send_timeout 60;

    proxy_read_timeout 60;
  }
}

//同上
server{
  listen 80;

  // @ 规则 *代表域名后缀
  server_name baidu.*;(baidu代指你自己的域名)
  location /{
    proxy_set_header Host $host:$server_port;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://localhost:9091/;
    proxy_connect_timeout 60;

    proxy_send_timeout 60;

    proxy_read_timeout 60;
  }
}

posted @   yurro  阅读(917)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示