banner
MiasaMoe

MiasaMoe

Building a Sub-Store using Docker and nginx on the Baota panel

This tutorial is aimed at beginners and simplifies the steps as much as possible. It is operated on the Baota panel, without involving complex configurations and advanced gameplay (such as notification functions and various scripts).

What is Sub-Store / Introduction#

Here is an excerpt from the official repository:

Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.

In order to avoid some risks as much as possible, I won't go into too much detail here. If you want to learn more, you can Google it yourself.
The main maintainer of the project: xream
Project repository: sub-store-org/Sub-Store

Preparations#

  • A VPS with a Baota panel installed and directly connected
    • Docker suite and nginx installed through the panel
  • It is best to have a domain name

Tutorial#

Create a storage directory for Sub-Store#

Sub-Store needs a directory to store your subscriptions and other files.

First, go to the Files tab of your panel and create a new folder in your desired location as the storage directory for Sub-Store.
Here, /etc/sub-store is used as an example. Please make a note of this directory anywhere.

Tip: You can click on the path bar to quickly get the absolute path of the current directory, just like in Windows.

Deploy Sub-Store with Docker#

The Baota panel does not open the 3001 port by default, so you need to add a port rule on the Security page, as shown in the figure:

Port Rule

Next, go to the Terminal page.

Here is a standard code:

docker run -it -d \
--restart=always \
-e "SUB_STORE_CRON=55 23 * * *" \
-e SUB_STORE_FRONTEND_BACKEND_PATH=/XXXXXxxxxx1234567890 \
-p YOURIP:3001:3001 \
-v /etc/sub-store:/opt/app/data \
--name sub-store \
xream/sub-store

Now let's modify it together:

  1. First, change the part after / in SUB_STORE_FRONTEND_BACKEND_PATH to a 20-character random string (without special characters). It is important to make it as random as possible, just like an API Token in other applications!
  2. Modify the directory after -v and before : to the directory you selected earlier to store Sub-Store data.
  3. Modify YOURIP after -p as needed.
    1. If you need to run and use it locally, please change it to 127.0.0.1.
    2. If you need remote access, please change it to server IP.
  4. Finally, if you have a need to use HTTP-META, please change xream/sub-store to xream/sub-store:http-meta. If you don't know what HTTP-META is, do not modify it.

Press Enter, and you should see a string of container IDs, indicating that it has been successfully run.
At this point, the Docker deployment is complete.

You can visit IP:3001 to see if it is running normally.

Use nginx reverse proxy (can be skipped without a domain name)#

Use nginx for reverse proxy so that you can access it through your own domain name.

Configuration & Binding#

Go to the Websites page, select the Reverse Proxy tab, and click Add Proxy to configure it.

The configuration is as shown in the figure:
Proxy Settings
Change sub.example.com in the figure to the domain name you want to bind, and replace yourip in the target with your server IP.
At this time, your Send Domain (host) column should display $http_host, and the remark should display your domain name.
After confirming that everything is correct, click Add.

Remember to use an A record to resolve the domain name you bound to your server IP in your domain name provider.

Configure SSL Certificate#

Find the reverse proxy rule you just configured, click Settings on the right, and go to the SSL tab. Select Let's Encrypt, choose the domain name, apply for a certificate, and the page should look like this:
SSL Certificate Configuration

Initial Use#

Next, you need to access a relatively complex address to activate and bind the backend.
Now there are two situations:

  1. If you are not using a domain name, please visit http://YOURIP:3001?api=http://YOURIP:3001/BACK_END_PASSWORD
  2. If you have bound your own domain name, please visit https://sub.example.com?api=https://sub.example.com/BACK_END_PASSWORD
    Replace YOURIP/DOMAIN with your server IP or domain name, and replace BACK_END_PASSWORD with the 20-character access key you set for the backend.

You should see the prompt Data refresh successful!. Go to Settings -> Backend Settings, and you should see a configuration similar to the following figure:
Backend Example

At this point, you have completed all the configurations. Enjoy the convenience brought by Sub-Store!

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.