Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使URL看起来更好_Url_Nginx - Fatal编程技术网

使URL看起来更好

使URL看起来更好,url,nginx,Url,Nginx,我不熟悉使用Nginx,所以目前我的默认文件中有这个 location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:3000; }

我不熟悉使用Nginx,所以目前我的默认文件中有这个

 location / {
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $remote_addr;
           proxy_set_header Host $host;
           proxy_pass http://127.0.0.1:3000;
        }

    location /templates/ {
              autoindex on;
              root /home/user/go/src/app/;
            }
因此,我的URL看起来像下面的链接,具体取决于我所在的页面:

http://localhost:80/templates/index.html
如何使Nginx重新格式化我的URL,使其看起来像:

http://localhost:80/index.html

必须像这样添加位置块

location / {
          # ...
          root /home/user/go/src/app/;
}

有关位置的详细信息

我已经有了这样的位置块,但是我上面介绍的代码指向了我的HTML文件所在的目录。如果web应用程序尚未使用该位置块,则可以替换该位置块