我正在尝试为我的网站(例如example.com)设置一个login页面,并且当有人在浏览器中键入“example.com”时,我想将自己的html作为要加载的页面进行加载。 我正在使用nginx作为我的networking服务器,但无法做到这一点。 我总是得到默认的“欢迎nginx”页面,而不是我的HTML。
这是我的nginx conf:
#user nobody; worker_processes 1; error_log /var/log/nginx/error.log; events { worker_connections 1024; } http { include mime.types; # include /usr/local/nginx/sites-enabled; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name example.com; access_log /var/log/nginx/access.log; location / { root /data/www; index test.html; } location /images{ root /data; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
这对这些url工作正常:
example.com/images/example.jpg, example.com/test.html
但我希望example.com拿起test.html,因为我给了位置'/'块索引模块。 但是example.com只是返回默认的“Welcome to nginx”页面。 任何人都可以帮我find这是什么问题吗? 我想承载的login页面没有任何url附件到example.com。 提前致谢。
尝试在“位置”块之外添加根和索引行:
... access_log /var/log/nginx/access.log; root /data/www; index test.html; location / { ...