Docker: nginx + wordpress + mysql + v2ray
date
May 13, 2022
slug
newservice-nginx-wordpress-mysql
status
Published
summary
新服务 一条龙 v2ray
tags
service
type
Post
URL
Summary一条龙 nginx+wordpress+mysql开启nginx + wordpress + mysql - 不需要mysql 配置,全自动查看upload大小设置加网站如果再加上v2ray tls+ws伪装验证
Summary
- 这样vps上就不用加 bt或者nginx之类的了
- 如果不需要nginx,参考这里步骤
一条龙 nginx+wordpress+mysql
开启nginx + wordpress + mysql - 不需要mysql 配置,全自动
DOCKER_MYSQL_ROOT_PASS=a8D72yp
DOCKER_MYSQL_USER_PASS=St4Ha9U
DOCKER_PROJ=nginx-wordpress-mysql-nwm
mkdir -p /data/$DOCKER_PROJ; cd /data/$DOCKER_PROJ
cat > uploads.ini <<EOF
file_uploads = On
upload_max_filesize = 256M #可以自己设置大小
post_max_size = 256M #可以自己设置大小
EOF
cat > docker-compose.yml <<EOF
version: '3.1'
services:
nginx:
image: lscr.io/linuxserver/nginx:latest
container_name: nwm-nginx
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Hong_Kong
volumes:
- ./nginx_config:/config
ports:
- 80:80
- 443:443
networks:
- default
db:
image: mariadb
container_name: nwm-mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: $DOCKER_MYSQL_ROOT_PASS
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: $DOCKER_MYSQL_USER_PASS
volumes:
- ./mariadb_mysql:/var/lib/mysql
networks:
- default
wordpress:
depends_on:
- db
image: wordpress:latest
container_name: nwm-wordpress
# no longer needed as forwarded by nginx
# ports:
# - "18880:80"
restart: always
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: $DOCKER_MYSQL_USER_PASS
volumes:
- ./wordpress_var_www_html:/var/www/html
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
networks:
- default
networks:
default:
EOF
# 启动容器
docker-compose down; docker-compose up -d; sleep 1s; docker-compose logs -f
查看upload大小设置
docker exec nwm-wordpress php -i | grep upload
加网站
cat > nginx_config/keys/ssl/wild-404.ee/privkey.pem <<EOF
-----BEGIN PRIVATE KEY-----
...
EOF
cat > nginx_config/keys/ssl/wild-404.ee/fullchain.pem <<EOF
-----BEGIN CERTIFICATE-----
...
EOF
SITE_URL='fun.404.ee'
mkdir -p nginx_config/keys/ssl/${SITE_URL}
cd nginx_config/keys/ssl/${SITE_URL}
ln -s ../wild-404.ee/privkey.pem privkey.pem
ln -s ../wild-404.ee/fullchain.pem fullchain.pem
cd /data/$DOCKER_PROJ
cat > nginx_config/nginx/site-confs/${SITE_URL} <<EOF
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
# use cloudflare orgin server certificates
ssl_certificate /config/keys/ssl/${SITE_URL}/fullchain.pem;
ssl_certificate_key /config/keys/ssl/${SITE_URL}/privkey.pem;
#HTTP_TO_HTTPS_START
if (\$server_port !~ 443){
rewrite ^(/.*)$ https://\$host\$1 permanent;
}
server_name ${SITE_URL};
location / {
proxy_pass http://wordpress;
proxy_http_version 1.1;
proxy_cache_bypass \$http_upgrade;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-Host \$host;
proxy_set_header X-Forwarded-Port \$server_port;
}
}
EOF
vi nginx_config/nginx/site-confs/${SITE_URL}
# proxy_pass http://wordpress;
# 有时候会多出一个 /
# 重启nginx
docker restart nwm-nginx; sleep 1; docker logs -f nwm-nginx
# tmp=`docker ps | grep nginx | awk '{print $1}' | head -n 1`; docker restart $tmp
如果再加上v2ray tls+ws伪装
vi /data/$DOCKER_PROJ/docker-compose.yml
# add appropriately
v2ray:
image: v2fly/v2fly-core
container_name: v2ray
#command: v2ray -config=/etc/v2ray/config.json
# new version 20230213
command: run -c /etc/v2ray/config.json
ports:
- 65432:65432
restart: always
environment:
TZ: Asia/Shanghai
volumes:
- ./v2ray:/etc/v2ray
vi nginx_config/nginx/site-confs/${SITE_URL}
# add properly
location /SoftDown {
proxy_redirect off;
proxy_pass http://v2ray:65432;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}