本指南提供了在服务器上设置Git仓库、将本地Hexo页面推送到服务器仓库、在服务器上创建Nginx配置文件以及在服务器上运行Nginx容器的方法。
请确保用适当的值替换所有<todo: comment>占位符。
There are several <todo: comment>
need to be replaced.
cd <todo: the path for repository>
git init
Reference: 部署 Hexo | Easy Hexo 👨💻
# Deployment
## ✨Docs: https://hexo.io/docs/one-command-deployment
deploy:
- type: git
repo: <todo: server user name>@<todo: server address>:<todo: server git repo absolute path>
branch: <todo: the branch will push>
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
# Set MIME types
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Set up logging
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
# SSL configuration
ssl_certificate /etc/nginx/ssl.pem;
ssl_certificate_key /etc/nginx/ssl.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
# HTTP server block to redirect to HTTPS
server {
listen 80;
server_name <todo: server name>;
return 301 https://$host$request_uri;
}
# HTTPS server block for the site
server {
listen 443 ssl http2;
server_name <todo: server name>;
root /usr/share/nginx/html;
index index.html;
# Set up SSL
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
resolver 1.1.1.1 1.0.0.1 8.8.8.8 valid=300s;
resolver_timeout 5s;
# Set up access logs
access_log /var/log/nginx/access.log main;
# Set up location for static files
location / {
try_files $uri $uri/ =404;
}
}
}
Reference: nginx - Official Image | Docker Hub
# pull nginx docker image
docker pull nginx
docker run \
--name <todo: container name> \
-v <todo: html path>:/usr/share/nginx/html:ro \
-v <todo: nginx.conf path>:/etc/nginx/nginx.conf:ro \
-v <todo: ssl key path>:/etc/nginx/ssl.key:ro \
-v <todo: ssl pem path>:/etc/nginx/ssl.pem:ro \
-p 80:80 \
-p 443:443 \
-d nginx
END.
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有