使URL看起来更好
我不熟悉使用Nginx,所以目前我的默认文件中有这个使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; }
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应用程序尚未使用该位置块,则可以替换该位置块