# 简介

Picsee-site是基于VUEPRESS开发的,基于它的目的, 是利用其MarkDown编写静态博客的功能,那么后期在推广时,可把功能点的介绍写成博文(基于MarkDown来写)。而站点首页的个性化展示,由于VUEPRESS是基于VUE开发的,利用tailwindcss样式库,自行基于VUE定制开发的。这样,就达到了目的,其一用MarkDown写博客,其二个性化某些页面,其三纯静态方便部署

# 运行站点

  • 环境:node(v12.5.0), npm(6.9.0)
  • 安装:npm install
  • 构建:npm run build
  • 运行:npm run dev

# 站点部署

站点采用集成部署,源码在GitHub上,利用Travis CI (opens new window)服务,只要git commit了,Travis CI就会自动构建,生成静态内容,然后根据秘匙设置,自动将生成的静态内容上传到服务器的指定目录,而在服务器上安装了nginx,已把指定目录作为web服务发布。

  • 站点remote master在github上Picsee-site (opens new window)
  • 集成服务 Travis CI, 相关教程 (opens new window)
  • 站点部署在服务器的 /www/picsee 和 /www/blog 目录,即资源文件在这里
  • nginx 配置文件如下, 在/etc/nginx/sites-available配置一个Config, 在/etc/nginx/enabled ln到它。[ln -s 原文件 链接的文件]
  • 阿里云开通80端口: https://www.aliyunfuwuqi.com/ecs/2254/
  • 阿里云SSL证书及安装过程: https://blog.csdn.net/weixin_44869002/article/details/108111218
  • 阿里云服务器套上cloudflare: https://blog.csdn.net/zhyl8157121/article/details/100551592

#############################################################################

# 20230604

# chitaner.com域名的配置

  1. 配置文件修改后的语法是否正确: nginx -t
  2. 重启服务: nginx -s reload
  3. nginx 配置如下:

server { listen 80 default_server; listen [::]:80 default_server; listen 443 http2 ssl; ssl_certificate /etc/chitaner.com.pem; ssl_certificate_key /etc/chitaner.com.key;

    server_name ~^(?<subdomain>.+).chitaner.com$;
    server_name chitaner.com;

   location / {

      
      if ($subdomain = "picsee") {
          root /var/www/picsee;
      }

      if ($subdomain = "blog") {
          root /var/www/blog;
      }

      if ($subdomain = "enpicsee") {
          root /var/www/enpicsee;
      }

      root /var/www/picsee; 
      index index.html; 

   }

    location /api/ {
            proxy_pass http://127.0.0.1:3000;
    }

    location /ray { # 与 V2Ray 配置中的 path 保持一致
      proxy_redirect off;
      proxy_pass http://127.0.0.1:9000;#假设WebSocket监听在环回地址的10000端口上
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host $http_host;

      # Show realip in v2ray access.log
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

#############################################################################

# 20230101

# Travis CI 集成 基于Github Action

  1. 目标: 站点需要切换到 45.77.4.124
  2. 配置在目录.github/workflows的deploy.yml中
  3. 需要配置: DEPLOY_KEY, SERVER_DESTINATION, SERVER_PORT, SSH_HOST, SSH_USERNAME
  4. 其中DEPLOY_KEY配置为SSH私钥
  5. 参考文章:https://frostming.com/2020/04-26/github-actions-deploy/

# Nginx配置

  1. nginx配置文件如下, 在/etc/nginx/sites-available配置一个Config, 在/etc/nginx/enabled ln到它。[ln -s 原文件 链接的文件]
  2. Server配置如下:

server { listen 80 default_server; listen [::]:80 default_server; listen 443 http2 ssl; ssl_certificate /etc/chitaner.com.pem; ssl_certificate_key /etc/chitaner.com.key; root /var/www/$subdomain;

    server_name ~^(?<subdomain>.+)\.chitaner\.com$;

    location /api/ {
            proxy_pass http://127.0.0.1:3000;
    }

    location /ray { # 与 V2Ray 配置中的 path 保持一致
      proxy_redirect off;
      proxy_pass http://127.0.0.1:9000;#假设WebSocket监听在环回地址的10000端口上
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host $http_host;

      # Show realip in v2ray access.log
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
    }

}

# 域名指向

  1. chitaner.com 管理在阿里云【购买,续期】
  2. 域名定向到IP, 在cloudfare: https://dash.cloudflare.com/48a40874f17c3b248236c08b3588680a
  3. 把chitaner.com的picsee.chitaner.com, blog.chitaner.com, blog.chitaner.com指向207.148.118.58

# 服务配置[版本升级提示服务]

  1. 参考Picsee-Server目录下的按照指示进行相关服务的按照

# V2RAY配置

  1. 参考PDF文档: 搭梯子:V2RAY配置WebSocket + TLS + Web.pdf
  2. Client端配置, 保存成 JSON, 在配置中 import 进来
{
  "routing" : {
    "name" : "all_to_main",
    "domainStrategy" : "AsIs",
    "rules" : [
      {
        "type" : "field",
        "outboundTag" : "chitaner.com",
        "port" : "0-65535"
      }
    ]
  },
  "inbounds" : [
    {
      "listen" : "0.0.0.0",
      "protocol" : "socks",
      "settings" : {
        "ip" : "127.0.0.1",
        "auth" : "noauth",
        "udp" : false
      },
      "tag" : "socksinbound",
      "port" : 1081
    },
    {
      "listen" : "0.0.0.0",
      "protocol" : "http",
      "settings" : {
        "timeout" : 0
      },
      "tag" : "httpinbound",
      "port" : 8001
    }
  ],
  "dns" : {
    "servers" : [
      "localhost"
    ]
  },
  "log" : {
    "error" : "\/var\/folders\/n8\/p8nvhyrs7nzb2fdn75yh3zwh0000gn\/T\/cenmrev.v2rayx.log\/error.log",
    "loglevel" : "none",
    "access" : "\/var\/folders\/n8\/p8nvhyrs7nzb2fdn75yh3zwh0000gn\/T\/cenmrev.v2rayx.log\/access.log"
  },
  "outbounds" : [
    {
      "sendThrough" : "0.0.0.0",
      "mux" : {
        "enabled" : false,
        "concurrency" : 8
      },
      "protocol" : "vmess",
      "settings" : {
        "vnext" : [
          {
            "address" : "chitaner.com",
            "users" : [
              {
                "id" : "ffbe15b7-12f2-442b-a024-7d0383aee5fe",
                "alterId" : 64,
                "security" : "auto",
                "level" : 1
              }
            ],
            "port" : 443
          }
        ]
      },
      "tag" : "chitaner.com",
      "streamSettings" : {
        "network" : "ws",
        "security" : "tls",
        "wsSettings" : {
          "path" : "\/ray"
        }
      }
    }
  ]
  1. Server端配置,
{
  "inbounds": [{
    "port": 9000,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "ffbe15b7-12f2-442b-a024-7d0383aee5fe",
          "level": 1,
          "alterId": 64
        }
      ]
    },
    "streamSettings":{
        "network":"ws",
        "wsSettings":{
                "path":"/spring"
        }
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      }
    ]
  }
}

#############################################################################

server {
        listen 80;
        listen 443 http2 ssl;
        ssl_certificate /etc/chitaner.com.pem;
        ssl_certificate_key /etc/chitaner.com.key;

        root /var/www/$subdomain;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name ~^(?<subdomain>.+)\.chitaner\.com$;


        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
        location /api/ {
                proxy_pass http://127.0.0.1:3000;
        }
}

server {
        listen 80;
        listen 443 http2 ssl;
        ssl_certificate /etc/gonger.club.pem;
        ssl_certificate_key /etc/gonger.club.key;

        root /www/$subdomain;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name ~^(?<subdomain>.+)\.gonger\.club$;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
        location /api/ {
                proxy_pass http://127.0.0.1:3000;
        }

        location /spring { # 与 V2Ray 配置中的 path 保持一致
          proxy_redirect off;
          proxy_intercept_errors on;
          proxy_pass http://127.0.0.1:9000;#假设WebSocket监听在环回地址的10000端
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header Host $http_host;
        }
}

server {
        listen 80;
        listen 443 http2 ssl;
        ssl_certificate /etc/chitaner.com.pem;
        ssl_certificate_key /etc/chitaner.com.key;

        root /www/$subdomain;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name ~^(?<subdomain>.+)\.chitaner\.com$;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
        location /api/ {
                proxy_pass http://127.0.0.1:3000;
        }

        location /spring { # 与 V2Ray 配置中的 path 保持一致
          proxy_redirect off;
          proxy_intercept_errors on;
          proxy_pass http://127.0.0.1:9000;#假设WebSocket监听在环回地址的10000端
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header Host $http_host;
        }
}


server {
    listen 80;
    server_name ~^(?<subdomain>.+)\.gonger\.xyz$;

    root     /var/www/html/owye.cc/public_html;
    index    index.html;
 
    # Context limits
    client_max_body_size 20M;
 
    # Disable access to sensitive files
    location ~* (app|content|lib)/.*\.(po|php|lock|sql)$ {
        deny all;
    }
 
    # Image not found replacement
    location ~ \.(jpe?g|png|gif|webp)$ {
        log_not_found off;
        error_page 404 /content/images/system/default/404.gif;
    }
 
    # CORS header (avoids font rendering issues)
    location ~ \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
        add_header Access-Control-Allow-Origin "*";
    }
 
    # Pretty URLs
    location / {
        index index.php;
        try_files $uri $uri/ /index.php$is_args$query_string;
    }
 
    location ~* \.php$ {
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        include         fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }
}

# 开发依赖

# 换IP操作

  • 在服务器完成克隆的情况下,vultr (opens new window)提供镜像复制服务
    • 域名指向需要更换, 在cloudflare中DNS设置
    • Travis CI 指向服务器需要更换 .travis.yml文件
    • v2ray 需要重新导出链接,设置客户端
  • 在服务器重新安装的情况下,需要安装服务器环境,后期准备制作docker镜像

# 域名说明

  • chitaner.com 购买于godaddy,在godaddy设置域名服务器在cloudflare
  • 域名服务器设置在cloudflare, 所在DNS设置在此
  • HTTPS证书设置在cloudflare, 证书下载

# 关于V2Ray

  • 在安装V2Ray后, 修改配置
    • 直接在命令行输入v2ray,安装操作提示,选择1,2, ... 提示操作
  • 未安装情况,见下

# 服务器环境

  • 服务器操作系统ubuntu 19.04
  • 安装nginx1.15.9 1. sudo apt update 2. sudo apt install nginx 3. sudo systemctl status nginx
  • 由于开启了HTTPS, 所以在nginx配置中,需要有 ssl_certificate /etc/chitaner.com.pem; ssl_certificate_key /etc/chitaner.com.key; 使用cloudflare的STL服务,key和pem在服务器中配置,详请见使用Cloudflare免费https证书 (opens new window)
  • 由于使用集成部署服务,Travis CI, 需要登录到服务器,ssh-keygen 生成密钥对之后,我们需要将 id_rsa_blog.pub 里面的内容,复制到服务器的 ~/.ssh/authorized_keys 文件里,详情见使用 Travis CI 实现 GitHub + Server 自动部署 (opens new window)
  • 安装V2Ray, 有一键安装脚本,并在本地备份了脚本

# 相关站点

# 换服务器地址

# nginx

  1. 配置文件修改后的语法是否正确: nginx -t
  2. 重启服务: nginx -s reload

# nginx 服务是否正确

  1. 查找当前监听端口: sudo netstat -tulpn | grep LISTEN

# 开机自启动

  1. 安装pm2: npm install pm2 -g
  2. 启动: pm2 start app.js
  3. 保存当前列表: pm2 save
  4. 设置开机启动: pm2 startup

# app指pm2创建的项目名

pm2 show app # 显示应用程序的所有信息 pm2 -h # 查看pm2帮助信息,显示命令用法 pm2 start app.js -n project # 将应用设置别名为project pm2 list # 显示所有项目 pm2 stop app # 停止应用服务 pm2 restart app # 重启应用服务 pm2 delete app # 在进程中删除应用 pm2 status # 查看状态 pm2 monit # 查看占用的CPU和内存

# 安装v2ray

  1. 参考:https://github.com/v2fly/fhs-install-v2ray
  2. 执行命令:
   bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

# 服务命令

  1. service nginx start/status/restart
  2. service v2ray start/status/restart

# v2ray server config in server

{
  "inbounds": [{
    "port": 9000,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "ffbe15b7-12f2-442b-a024-7d0383aee5fe",
          "level": 1,
          "alterId": 64
        }
      ]
    },
    "streamSettings":{
        "network":"ws",
        "wsSettings":{
                "path":"/spring"
        }
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      }
    ]
  }
}

# v2ray client config on pc

{
  "outbounds" : [
    {
      "sendThrough" : "0.0.0.0",
      "mux" : {
        "enabled" : false,
        "concurrency" : 8
      },
      "protocol" : "vmess",
      "settings" : {
        "vnext" : [
          {
            "address" : "chitaner.com",
            "users" : [
              {
                "id" : "ffbe15b7-12f2-442b-a024-7d0383aee5fe",
                "alterId" : 64,
                "security" : "auto",
                "level" : 1
              }
            ],
            "port" : 443
          }
        ]
      },
      "tag" : "chitaner.com",
      "streamSettings" : {
        "network" : "ws",
        "security" : "tls",
        "wsSettings" : {
          "path" : "\/spring"
        }
      }
    }
  ],
  "routings" : [
    {
      "name" : "all_to_main",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "bypasscn_private_apple",
      "domainStrategy" : "IPIfNonMatch",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "domain" : [
            "localhost",
            "domain:me.com",
            "domain:lookup-api.apple.com",
            "domain:icloud-content.com",
            "domain:icloud.com",
            "domain:cdn-apple.com",
            "domain:apple-cloudkit.com",
            "domain:apple.com",
            "domain:apple.co",
            "domain:aaplimg.com",
            "domain:guzzoni.apple.com",
            "geosite:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "direct",
          "ip" : [
            "geoip:private",
            "geoip:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_direct",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_main",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "bypasscn_private_apple",
      "domainStrategy" : "IPIfNonMatch",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "domain" : [
            "localhost",
            "domain:me.com",
            "domain:lookup-api.apple.com",
            "domain:icloud-content.com",
            "domain:icloud.com",
            "domain:cdn-apple.com",
            "domain:apple-cloudkit.com",
            "domain:apple.com",
            "domain:apple.co",
            "domain:aaplimg.com",
            "domain:guzzoni.apple.com",
            "geosite:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "direct",
          "ip" : [
            "geoip:private",
            "geoip:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_direct",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_main",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "bypasscn_private_apple",
      "domainStrategy" : "IPIfNonMatch",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "domain" : [
            "localhost",
            "domain:me.com",
            "domain:lookup-api.apple.com",
            "domain:icloud-content.com",
            "domain:icloud.com",
            "domain:cdn-apple.com",
            "domain:apple-cloudkit.com",
            "domain:apple.com",
            "domain:apple.co",
            "domain:aaplimg.com",
            "domain:guzzoni.apple.com",
            "geosite:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "direct",
          "ip" : [
            "geoip:private",
            "geoip:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_direct",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_main",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "bypasscn_private_apple",
      "domainStrategy" : "IPIfNonMatch",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "domain" : [
            "localhost",
            "domain:me.com",
            "domain:lookup-api.apple.com",
            "domain:icloud-content.com",
            "domain:icloud.com",
            "domain:cdn-apple.com",
            "domain:apple-cloudkit.com",
            "domain:apple.com",
            "domain:apple.co",
            "domain:aaplimg.com",
            "domain:guzzoni.apple.com",
            "geosite:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "direct",
          "ip" : [
            "geoip:private",
            "geoip:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_direct",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_main",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "bypasscn_private_apple",
      "domainStrategy" : "IPIfNonMatch",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "domain" : [
            "localhost",
            "domain:me.com",
            "domain:lookup-api.apple.com",
            "domain:icloud-content.com",
            "domain:icloud.com",
            "domain:cdn-apple.com",
            "domain:apple-cloudkit.com",
            "domain:apple.com",
            "domain:apple.co",
            "domain:aaplimg.com",
            "domain:guzzoni.apple.com",
            "geosite:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "direct",
          "ip" : [
            "geoip:private",
            "geoip:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_direct",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_main",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "bypasscn_private_apple",
      "domainStrategy" : "IPIfNonMatch",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "domain" : [
            "localhost",
            "domain:me.com",
            "domain:lookup-api.apple.com",
            "domain:icloud-content.com",
            "domain:icloud.com",
            "domain:cdn-apple.com",
            "domain:apple-cloudkit.com",
            "domain:apple.com",
            "domain:apple.co",
            "domain:aaplimg.com",
            "domain:guzzoni.apple.com",
            "geosite:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "direct",
          "ip" : [
            "geoip:private",
            "geoip:cn"
          ]
        },
        {
          "type" : "field",
          "outboundTag" : "main",
          "port" : "0-65535"
        }
      ]
    },
    {
      "name" : "all_to_direct",
      "domainStrategy" : "AsIs",
      "rules" : [
        {
          "type" : "field",
          "outboundTag" : "direct",
          "port" : "0-65535"
        }
      ]
    }
  ]
}