nginx - 无法在 Nginx 中配置子域
问题描述
经过 4 个小时的奋斗和互联网挖掘,我似乎无法理解为什么这个 Nginx 配置不起作用。
目标:
我有两个完全不同的项目,我想使用子域将它们托管在同一个域上。所以项目一将是one.example.com
,而项目二必须是two.example.com
。我还在端口上设置了两个不同的节点 js 服务器4000
,4001
并且希望将项目一路由到4000
并将项目二路由到4001
.
server {
listen 80;
server_name one.example.com;
location / {
proxy_pass http://127.0.0.1:4000/;
}
}
server {
listen 80;
server_name two.example.com;
location / {
proxy_pass http://127.0.0.1:4001/;
}
}
使用的命令:service nginx start
我得到的错误
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
解决方案
为了解决我的问题,我必须/etc/nginx/nginx.conf
将这一行添加到 http server 块的顶部:server_names_hash_bucket_size 64;
推荐阅读
- css - 为什么这个元素的宽度不为0?
- python - 如何计算数据集的行完整性?
- sql - SQL 一个计数行中有多少行在另一个计数行中?
- javascript - 我应该在哪里存储用户首选项或用户设置 - localStorage 或 cookie?
- sql - 尝试使用合并语句使触发器起作用
- r - Rstudio 中的管道命令停止工作
- arrays - 这是 c 中按频率排序的数组
- python - 如何为 Seaborn 中的三个子图之一设置刻度?
- amazon-web-services - AWS - 使用 Bamboo 管道执行位于 S3 中的 sh 文件
- optimization - 分布样本的概率