“ location”标记中的网址匹配有什么问题?

时间:2019-01-22 11:22:07

标签: nginx nginx-location

这是我在Debian上使用nginx的第一次经验。 因此,我在/var/www/gis/index.html中放置了一个html页面 我将nginx配置为:

server {
        listen 80;
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name localhost;

        ssl_certificate /etc/ssl/certs/localhost.crt;
        ssl_certificate_key /etc/ssl/private/localhost.key;

        ssl_protocols TLSv1.2 TLSv1.1 TLSv1;

        location / {

        root /var/www/gis;
        index index.html;

        }

如果在浏览器中输入https://localhost,我可以看到我的页面。 但是如果我将位置标记更改为

        location /gis {  ## or location = /gis ##)

        root /var/www/gis;
        index index.html;

        }

我希望我的网站位于https://localhost/gis/,但出现错误404。我做错了什么?

1 个答案:

答案 0 :(得分:1)

使用此配置,nginx希望在int处找到您的index.html。您可以使用

/var/www/gis/gis/

location /gis {
    root /var/www;
    index index.html;
}