[英]Need help setting up Hexo Blog with NGINX
我需要在我的Droplet上建立博客的幫助。 我已經使用Hexo在blog.mysite.io上成功部署了博客,但問題是hexo博客將其重定向到blog.mysite.io/blog/public 。 現在,我知道它為什么會發生,這是因為我將博客配置設置為:
_config.yml
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://blog.mysite.io/
root: /blog/public
permalink: :year/:month/:day/:title/
我的博客在/ www / data / blog中 。 我將根目錄設置為/ blog / public的原因是,如果沒有,css和其他所有內容都會中斷。 該博客運行正常,但只有HTML部分。
這是nginx vhosts.conf配置:
server {
server_name blog.mysite.io;
root /www/data/blog/public;
index index.html index.htm;
location /
{
proxy_pass http://127.0.0.1:4000;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/blog.mysite.io/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/blog.mysite.io/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
除上述設置外,任何其他操作都會導致完全中斷站點或路徑不匹配。 因此,如何直接在blog.mysite.io服務我的網站?
需要更換root: /blog/public
與root: /
在HEXO配置。
Nginx可以使用root /www/data/blog/public;
目錄找到您站點目錄的完整路徑root /www/data/blog/public;
指示。
您還可以在Nginx配置的末尾添加以下設置:
location / {
# for static content
root /www/data/blog/public;
index index.html;
# custom 403/404 redirect
error_page 403 404 =404 /404/;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.