3
我想配置nginx到服務器的HTML文件來查看而不是下載。如何配置nginx以提供HTML文件進行查看而不是下載?
server {
listen 5000;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#location/{
# root html;
# index index.html index.htm;
#}
location =/{
root /home/vagrant/own/base/assets;
index index.html;
}
location = /login {
# root /home/vagrant/own/base/assets;
alias /home/vagrant/own/base/assets/login.html;
}
location /index.html {
root /home/vagrant/own/base/assets;
}
}
這是我的conf文件,當我瀏覽到/login
,我的瀏覽器嘗試提供下載的文件,而不是觀看它。謝謝你的幫助。
location =/login {root/home/vagrant/own/base/assets; 類型{application/octet-stream html; } alias /home/vagrant/own/base/assets/login.html; } 是否這樣? – zimmer
如果答案是正確的,請將其標記爲答案,然後帖子的狀態將被調整爲'已回答' –
這對我來說不起作用。它只需下載login.html @Shayan Ghosh – zimmer