【发布时间】:2018-02-28 23:35:37
【问题描述】:
我通过 nginx 配置一个静态站点,并将我的设置包含在 conf.d 目录下。监听 80 端口。
但是我在请求url的时候发现,nginx总是重定向默认页面/usr/share/nginx/html/index.html
我的配置似乎确实有效,因为所有访问日志都写入了我的访问日志设置,如果我在我的目录中将 index.html 更改为其他名称(例如 i.html),并请求 url mysite.com/ i.html,我可以访问正确的页面。
所以,似乎 nginx 将所有 index.html 重定向到默认的。
我尝试更改默认端口/服务器名称/root并注释默认设置,甚至关闭selinux,以上都不起作用,这真的让我很生气。
谁能帮帮我?
我在 CentOS 7.2 上使用 nginx 版本 1.10.2
以下是我的网站设置:
# the upstream component nginx needs to connect to
upstream blog {
server 0.0.0.0:80; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# the domain name it will serve for
server_name mysite.com;
charset utf-8;
access_log /var/log/blog/access.log;
error_log /var/log/blog/error.log;
# max upload size
client_max_body_size 75M; # adjust to taste
# Finally, send all non-media requests to the Django server.
location / { try_files $uri @blog; }
location @blog{
root /home/work/projects/blog/public/;
index index.html index.htm;
uwsgi_read_timeout 120s;
uwsgi_send_timeout 120s;
}
}
而 /etc/nginx/nginx.conf 是
server {
# listen 8000 default_server;
# listen [::]:8000 default_server;
# server_name not;
# root /usr/share/nginx/html;
# Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
# location / {
# }
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
【问题讨论】:
标签: nginx