83 lines
2.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 运行 有问题不能使用
mkdir -p /root/docker/nginx/conf
mkdir -p /root/docker/nginx/html
mkdir -p /root/docker/nginx/log
mkdir -p /root/docker/nginx/ssl
```
docker run -d --restart=always --name nginx-web \
-v /root/docker/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /root/docker/nginx/html:/usr/share/nginx/html \
-v /root/docker/nginx/log:/var/log/nginx \
-v /root/docker/trojan/:/root/docker/trojan \
-v /etc/localtime:/etc/localtime:ro \
-p 80:80 \
nginx
```
## 默认配置地址
https://github.com/nginx/nginx/blob/master/conf/nginx.conf
记得修改
```
location / {
root html;
index index.html index.htm;
}
```
```
location / {
root /usr/share/nginx/html/;
index index.html index.htm;
}
```
修改完配置后需要重启docker容器。
## 默认路径
/usr/share/nginx/html/
## 有关DNS
~~默认的域名blueroses.top是指向cloudflare的所以通过域名来访问SFTP需要访问在cloudflare设置的子域名~~。然而是cloudflare域名解析的问题。
- tj.blueroses.top
- www.blueroses.top
因为还添加了阿里云DNS解析所以更换VPS时需要记得**修改阿里云的DNS设置**。
## VPS Blog部署
其他方法都或多或少的比较麻烦所以最后用SFtp。
### SFtp
```
docker run --privileged --name sftp \
-v /root/docker/nginx/html:/home/web/ \
-p 2222:22 -d atmoz/sftp \
web:web:1000:1000:web
```
账号密码结为web,遇到权限问题,需要设置一下目录权限。
chmod -R 666 /docker/nginx/html/
```
docker run --name mysftp -p 2294:22 -d atmoz/sftp foo:pass:::upload
--name mysftp  容器名称
foo:pass:::upload  其中foo为用户名pass为密码upload为上传的文件会保存到容器里面的/home/foo/upload目录里面
-p 22:22  将宿主机的22端口映射到容器的22端口这样方位宿主机的22端口则会转发到容器的22端口上
-d atmoz/sftp  使用dockup hub中的atmoz/sftp镜像创建容器
```
### githook
因为使用docker所以没法直接执行bash。
```
rm -rf /docker/nginx/test/
mkdir /docker/nginx/test/
git clone /docker/gitea/git/repositories/bluerose/blog.git /docker/nginx/test/
rm -rf
cp -rf /docker/nginx/test/ /docker/nginx/html/
```
```
GIT_REPO=/docker/gitea/git/repositories/bluerose/blog.git \
TMP_GIT_CLONE=/docker/test/ \
PUBLIC_WWW=/docker/nginx/html/ \
rm -rf ${TMP_GIT_CLONE} \
mkdir ${TMP_GIT_CLONE} \
git clone $GIT_REPO $TMP_GIT_CLONE \
cp -rf ${TMP_GIT_CLONE} ${PUBLIC_WWW}
```