首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多域和子域的Nginx反向代理

问多域和子域的Nginx反向代理
EN

Server Fault用户
提问于 2018-10-25 05:45:01
回答 1查看 6.3K关注 0票数 2

我拥有运行不同站点的服务器,我需要为这些域配置nginx反向代理(example1.com、example2.com、test.example1.com),其中dp需要为反向代理配置nginx中的域。

EN

回答 1

Server Fault用户

发布于 2018-10-25 07:17:19

多个server{}块和proxy_pass http://origin.server在location块中。

例如:

代码语言:javascript
复制
server {
  test.example1.com;
  location / {
     proxy_pass http://origin.text.example1.com;
  }
}
server {
  server_name example1.com;
  location / {
     proxy_pass http://origin.example1.com;
  }
}
server {
  server_name example2.com;
  location / {
     proxy_pass http://origin.example2.com;
  }
}

nginx初学者指南和nginx文档中的服务器名称会帮你的。

还有更复杂的配置(包括/etc/nginx/sites启用/..conf、/etc/nginx/sites available /..conf),但这依赖于您的分发包。

票数 4
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/937103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档