前情概要
趁着服务器便宜买了,就想着把自建的 blog 恢复回来。 但是 blog 服务端口是 8081, 想直接在 ip 访问或者域名访问的时候不带端口。这时候 nginx 就发挥作用啦。
博客访问地址
第一步:查找配置文件地址
> sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
/etc/nginx/nginx.conf
则是我们要找的地址啦
第二步: 配置转发
贴关键代码, 主要是转发
8081 是服务实际端口
server {
server_name www.mimeay.cc
listen 80;
location / {
proxy_pass http://127.0.0.1:8081;
}
}
# 因为域名还在备案,所以同时配了ip的
server {
server_name 121.5.147.47
listen 80;
location / {
proxy_pass http://127.0.0.1:8081;
}
}
第三步:重启服务, 大功告成
> sudo nginx -s reload
其他 nginx 命令
关闭 nginx
sudo nginx -s stop
打开 nginx
sudo nginx
应该会写的系列文章
- nodejs 的安装
- mysql 安装及问题解决
- ghost blog 初始化
- Nginx 转发部分【已完成】
- 网站备案【已完成】
网友评论