沉冰浮水

沉冰浮水

做最终到的事,成为最终成为的人!
github
bilibili
mastodon
zhihu
douban

「折騰」Docker + Nginx 內映射子目錄站點及自定義規則

Due to unexpected reasons, the system was reinstalled. Although WSL2 was backed up, the backup files were too large, so I decided to reinstall from scratch.

In addition, the previous Z-BlogPHP In Docker was deployed using docker run, but it seems more convenient to switch to docker-compose.

Because I wrote some "GM scripts" that can only be recognized and installed by browser plugins through web services, it seems unnecessary to open a separate service for them. Therefore, I chose to implement them as subdirectories of Z-Blog.

http://127.0.0.1:8081/userscript ← like this;

At the same time, the "directory browsing" function (autoindex) needs to be enabled for this path.

Place the files in the site directory that will be mounted into Docker according to the following path and write the content:

# zbp_folder/vhost.d/5-GM_JS.conf

# Block access to vhost.d/ itself
location /vhost.d/ {
    return 404;
}

# Configuration options for userscript/
location /userscript/ {
    autoindex on;
    autoindex_localtime on;
    add_header Cache-Control no-store;
}

The following is a mounting example:

docker run deployment:

ZBP_DIR=~/wwwroot/zbp_folder
ZBP_PORT=8081
VHOST_DIR=$ZBP_DIR/vhost.d
sudo docker run --name zbp \
  --net=net_web \
  -v $ZBP_DIR:/app \
  -v ~/Git/userscript:/app/userscript \
  -v $VHOST_DIR/5-GM_JS.conf:/opt/docker/etc/nginx/vhost.common.d/5-GM_JS.conf \
  -e XXXXX \
  -p $ZBP_PORT:80 \
  --restart on-failure \
  -d wdssmq/zblogphp

docker-compose deployment:

volumes:
    - ./www/zbp_folder:/app
    - ~/Git/userscript:/app/userscript
    - ./www/zbp_folder/vhost.d/5-GM_JS.conf:/opt/docker/etc/nginx/vhost.common.d/5-GM_JS.conf

· Related recommendations:

"Experiment" Compressing WSL2 Disk Usage_Computer Network_Ice and Water
https://www.wdssmq.com/post/20100428905.html

"Experiment" Dockerizing Z-BlogPHP Installation_Computer Network_Ice and Water
https://www.wdssmq.com/post/20120817544.html

"Experiment" Writing GM Scripts Using Rollup.js Module_Computer Network_Ice and Water
https://www.wdssmq.com/post/20120627834.html

Pseudo-static Related to php-nginx in Docker_Computer Network_Ice and Water
https://www.wdssmq.com/post/20190813019.html

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。