Server

nps reverse proxy

  • Project here.
  • Official Doc
  • There are also NginxProxyManager, NginxWebUI, etc. that have the same effect. Take time to test in the future
  • nps also has some awesome operations, friends who are interested, we can communicate individually
  • If there is any problem, welcome to leave a message and give feedback, we will make progress together.

Install

Go to releases of the project address to check the release version of corresponding system, for example, my server is ubuntu-amd64, expand assets, and find linux_amd64_server .tar.gz, server is the server, client is the client.

  • The link address of the following example is time-sensitive, please go to releases to view the latest version.

  • It is recommended to create a new directory to store the project.

    • mkdir -p /nps/ && cd /nps
  • Pull down the corresponding installation package.

    • wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz
  • Client Downloads

    • wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_client.tar.gz
  • tar

    • tar -zxvf linux_amd64_client.tar.gz && rm linux_amd64_client.tar.gz && tar -zxvf linux_amd64_server.tar.gz && rm linux_amd64_server.tar.gz
  • After decompression is complete.sudo ./nps install

  • nps start

  • Check the project port before starting,netstat -tnlp | grep :80,Mainly check whether there are ports occupied, similarly check ports 8080 and 8024, if there are services occupied, consider replacing the corresponding port in the configuration file

  • Access server ip: web service port (8080 by default)

  • Login test with username and password (default admin/123)

  • After logging in, there is no problem

    • nps stop
  • if something goes wrong

    • cat /var/log/nps.log to see what’s the problem.

Configuration

  • nano /etc/nps/conf/nps.conf

It is recommended to modify some items, and other configuration items can be checked when needed official document.

web_port Port for web management, default 8080
web_password Password for the web interface
web_username Account for the web page
web_base_url Modifying this item can improve security to a certain extent. For example, if your domain name is xxx.com, then this item is set to /management, and you must use xxx.com/management to access the management page
bridge_port You can understand it as a communication port that must be opened, and communicate with the client through this port
https_proxy_port By default, it listens to port 443, which will be used when proxying domain names. It is not recommended to change to other ports
http_proxy_port By default, it listens to port 80, which will be used when proxying domain names. It is not recommended to change to other ports
auth_crypt_key It is recommended to replace the default and keep 16 bits
public_vkey When your client needs to start with a configuration file, it is recommended to replace the default
  • Start nps start to enter the management page

  • If you need to configure reverse generation of the domain name in the local vps, for example, proxy my portainer on port 9000 to the domain name portainer.xxx.com, and add an nps client

    • Manage the page, sidebar, client, add, fill in the notes, nothing else is necessary
    • Record the ID of the client list, and the unique authentication key
    • Go back to the npc you downloaded earlier
    • ./npc install -server=ip:port -vkey=the key displayed in the web interface - the port here is the bridge_port you configured earlier, and the vkey is filled with unique verification key
    • run sudo npc start
    • On the nps management page, on the left sidebar, domain name resolution, add, client ID fills in the ID recorded earlier, the host writes the domain name of the reverse proxy, for example, mine is portainer.xxx.com, and then Fill in Target, here it should be noted that the filling form is IP:Port, follow the prescribed form

    The pit that I have stepped on

    • Do not modify web_open_ssl=false, :sweat_smile: in nps.conf, unless you know how to configure ssl on the management side, otherwise you will not be able to enter the control panel like me.
    • The ssl setting of the open page is https_proxy_proxy, set it to false, add the configuration options in the domain name, generally add the certificate and secret key, open https in your dns service provider, and develop a good habit of nps restart after modifying the configuration
    • Cloudflare dns resolve method can set the flexible method is ok. The complete and strict methods will report an error. No solution has been found so far. I will update later.
    • When you encounter unsolvable problems.
    • nps stop
    • nps uninstall
    • ps -ef | grep nps
    • kill -9 “process id”
    • find / -name nps
      - use rm -rf about nps in \usr \tmp \etc \bin
      - Don’t step on a pit, don’t delete the folder of linux head in \usr, otherwise the consequences will be serious
    • Reinstall nps, reconfigure

Install the Chinese version of Portainer

Details in Docker hub.

# just one command
docker run -d --restart=always --name="portainer" -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock 6053537/portainer-ce

Deploy filebrowser

Details in Docker hub.

Official Doc, There are some problems with the official tutorial, the specific deployment is subject to the following command.

# one command
docker run -d --name="filebrowser" -v /data/filebrowser/files:/srv -v /data/filebrowserconfig.json:/etc/config.json -v /data/filebrowser/database.db:/etc/database.db -p 9001:80 filebrowser/filebrowser

Limit the quota of filebrowser

Ref:https://www.cnblogs.com/dechinphy/p/limits.html, https://blog.csdn.net/peterhunter0320/article/details/120191436

Example: My file directory is stored in /data

dd if=/dev/zero of=/file.img bs=512M count=10
# 这里解释一下,dd用于生成镜像文件,if=/dev/zero(指定源文件为/dev/zero,/dev/zero用于初始化空文件),of=/file.img(指定目的文件为根目录下的file.img),块大小为512x10,为什么不直接5120M,如果你的内存空间大于5120M没有问题,可以直接bs=5120M count=1,就比如我的内存为2G,将写入量5G分10次写入才可以,具体自己分配
losetup -f
# 我的输出是/dev/loop0,对应下行命令
losetup /dev/loop0 /file.img
mkfs.ext4 /dev/loop0
losetup -d /dev/loop0
mount -o loop /file.img /data
df -h
# 你就可以看到 /data已经被挂载到了/dev/loop0了,Size限定为5G

Supplement:

  • mkfs.ext4 /dev/loop0 -N 5
  • The disk format is ext4, and the number of folders is limited to 5
  • unmount file,umount /data
  • Unmount the loop device associated with the file,losetup -d /dev/loop0

Doploy stackedit

Details in 项目地址

docker run -itd --name stackedit -p 9002:8080 -e LISTEN_PORT=8080 -e ROOT_URL=/ -e USER_BUCKET_NAME=root mafgwo/stackedit:5.15.19-2

Deploy netdata

Details in Docker hub.

docker run -d --name=netdata   -p 9003:19999   -v /proc:/host/proc:ro   -v /sys:/host/sys:ro   -v /var/run/docker.sock:/var/run/docker.sock:ro   --cap-add SYS_PTRACE  --security-opt apparmor=unconfined   172721404/netdata_with_chinese

Write in the end

Due to academic pressure, I will continue to improve this article when I have time later. If there are any problems in the actual operation, please communicate with me in the comment area.