【发布时间】:2016-12-14 21:45:47
【问题描述】:
我目前有一个域,并尝试在我的服务器上托管两条路径:domainB.com 和 domainB.com/blog。
我希望访问 domainB.com/blog 并将其设置为 blog,但是当我尝试这样做时,我收到以下错误:
2016/12/14 16:33:45 [warn] 1026#0: conflicting server name "domainB.com" on 0.0.0.0:80, ignored
2016/12/14 16:33:46 [error] 1039#0: *1 open() "/home/www/flask-deploy/blog/404.html" failed (2: No such file or directory), client: 195.154.199.56, server: domainB.com, request: "GET /license.php HTTP/1.0", host: "www.domainB.com"
2016/12/14 16:34:31 [error] 1039#0: *10 directory index of "/home/www/flask-deploy/blog/" is forbidden, client: xxx.xx.xx.xxx, serve
已更新 - 此配置看起来如何?
upstream siteb {
server http://localhost:8001;
}
upstream siteb-blog {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name siteb.com;
root /home/www/flask-deploy/siteb;
location / {
#proxy_pass http://localhost:8001;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
fastcgi_pass siteb;
}
location /static {
alias /home/www/flask-deploy/siteB/static/;
}
location ~* ^/blog/ {
root /home/www/flask-deploy/siteb-blog;
try_files $uri $uri/ /blog/index.php?$query_string;
location ~ \.php$ {
fastcgi_pass siteb-blog;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
}
但是,当我尝试访问:siteB.com/blog - 我得到一个404 error。
我在这里做错了什么?
谢谢!
【问题讨论】:
-
nginx不能有两个server块具有相同的server_name和端口。请参阅this document 了解更多信息。 -
@RichardSmith 你是怎么解决的?那么,我是否需要将它们添加到相同的配置中并使
1具有server_namedomainB.com和2具有server_namedomainB.com/blog? -
@RichardSmith - 请提供一个例子的答案。对于我的情况,您提供的这份文件很难理解
标签: nginx configuration webserver