Configure Nginx as a Reverse Proxy

Modify the Nginx configuration to act as a reverse proxy. Edit the Nginx site configuration file:

sudo vi /etc/nginx/sites-available/default

Update the following server block at the bottom (replace [yourDomain.com] and adjust the [YOUR_APP_PORT] to match your application):

server {
        listen 443 ssl;
#       listen [::]:80;

        server_name [yourDomain.com];
        ssl_certificate /etc/letsencrypt/live/[yourDomain.com]/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/[yourDomain.com]/privkey.pem;
#       root /var/www/example.com;
#        index index.html;

        location / {
#               try_files $uri $uri/ =404;
                proxy_pass http://localhost:[YOUR_APP_PORT];
                proxy_http_version 1.1;
                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;
        }
}

restart it to apply your changes:

sudo systemctl restart nginx

You should be able to access your web application over HTTPS by visiting https://[yourDomain.com]

Setting a New Static IP Address

Open the dhcpcd configuration file:

sudo vi /etc/dhcpcd.conf

Set the static IP address: At the end of the file, add the following lines, replacing the example network information with your own:

interface eth0
static ip_address=192.168.1.XX/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8

Here, 192.168.1.XX is the new IP address you wish to assign to your server. Ensure this IP address is not already in use within your local network.

sudo sync;sudo /sbin/shutdown -r now

Quick Fixes for WiFi Disconnection on Ubuntu

Method 1: Disable WiFi Power Management

Ubuntu might automatically turn off WiFi to save power. Here’s how to stop that:

  1. Check Your Network Interface Name: Use
    iwconfig
    to find your network interface name (it’s wlan0 for many but can differ).
  2. Turn Off Power Management: Execute
    sudo iwconfig wlan0 power off
    , replacing wlan0 with your actual interface name.

Method 2: Edit NetworkManager Configuration

Prevent automatic disconnections by tweaking NetworkManager:

  1. Open Configuration File: Run
    sudo vi /etc/NetworkManager/NetworkManager.conf.
  2. Add Power Save Setting: Insert the following lines:
    [connection]
    wifi.powersave = 2
  3. Restart NetworkManager: Apply changes with
    sudo systemctl restart NetworkManager.

Encountered “Operation not supported”? If disabling power management directly doesn’t work, try this alternative:

Alternative Method: Use TLP for Advanced Power Management

TLP offers granular control over power settings, including WiFi:

  1. Install TLP: Update your system and install TLP with
    sudo apt update
    followed by
    sudo apt install tlp tlp-rdw.
  2. Start TLP: Activate TLP using
    sudo tlp start.
  3. Edit TLP Configuration: Modify
    /etc/tlp.conf
    to disable WiFi power management. Uncomment (or add) the lines:
    WIFI_PWR_ON_AC=off
    WIFI_PWR_ON_BAT=off
  4. Restart TLP: Make your changes effective with
    sudo tlp start

Spotfire Server 12.0.8とOpenID Connect連携の設定方法

Microsoftのアイデンティティプラットフォームには、IDトークンのv1.0版とv2.0版の2種類があります。これらのバージョンは、トークンに含まれるクレームを決定します。v1.0とv2.0のIDトークンは、それぞれが持つ情報に違いがあります。トークンのバージョンは、それが要求されたエンドポイントに基づいています。新しいアプリケーションはv2.0を使用するべきです。

v1.0の認証エンドポイント: https://login.microsoftonline.com/common/oauth2/authorize
v2.0の認証エンドポイント: https://login.microsoftonline.com/common/oauth2/v2.0/authorize

上記の2種類のトークン、v1.0とv2.0は登録時に両方使用可能ですが、v2.0が推奨されています。登録プロセスについては、以下の手順を参照してください:

1) https://portal.azure.com にログインし、「Microsoft Entra ID」セクションでアプリケーションを登録します。

2) 「アプリ登録」->「新規アプリケーション登録」をクリックします。別のページが表示され、フィールド名、アプリケーションタイプ(Webapp/API)、および「リダイレクトURL」を入力する必要があります。

3) TIBCO Spotfireサーバー設定でカスタムのパブリックアドレスを有効にします。

4) UIConfigの「OpenID Connect」タブを選択し、OpenID Connectを有効にします。

5) Azureで、登録済みのアプリケーションをクリックします。Spotfireサーバー設定ツールからのリターンエンドポイントURL、アプリケーションID、テナントID、オブジェクトIDが表示されます。

6) 「クライアントシークレット」の取得方法:「証明書&シークレット」をクリックし、「新規クライアントシークレット」をクリックし、説明と期間を入力して保存します。フィールドにキーが生成されるので、クリップボードにコピーします。

7) UIConfig->設定->「Web認証(例:OpenID Connect)」を選択します。

8) UIConfig->「OpenID Connect」->「新規プロバイダー追加」をクリックします。プロバイダー名、ディスカバリードキュメントURL、クライアントID、クライアントシークレットを指定します。

a) UIConfig >> Discovery document URL: https://login.microsoftonline.com/{tenant}/.well-known/openid-configuration
「Azure Active Directory」>>「アプリ登録」>> アプリ選択 >> 「テナントID」を参照します。
例:https://login.microsoftonline.com/55e98fdf-9ac4-42f6-a35d-6bcb4d9b4bc7/.well-known/openid-configuration
b) UIConfig >> クライアントIDは「アプリケーションID」です。
c) UIConfig >> クライアントシークレットは、アプリからAzureによって生成された「シークレットキー」です。

さらに詳細な情報は以下のリンクで確認できます:

例:

番号項目名
 1.Configuration Start -> AuthenticationWeb Authentication(e.g. OpenID Connect)
 2.Configuration Start -> User directoryDatabase
 3.OpenID Connect -> Enable OpenID ConnectYes
 4.OpenID Connect -> Enable Third Party Login InitiationYes
 5.OpenID Connect -> Enable RP-Initiated LogoutNo
 6.OpenID Connect -> Enable Back-Channel LogoutNo
 7.OpenID Connect -> Enable Front-Channel LogoutNo
 8.OpenID Connect -> Return Endpointhttps://[FQDN]/spotfire/auth/oidc/authenticate
 9.OpenID Connect -> Third Party Login Initiation Endpointhttps://[FQDN]/spotfire/auth/oidc/v1/initiate
 10.OpenID Connect -> EnabledYes
 11.OpenID Connect -> Provider nameAzure
 12.OpenID Connect -> Discovery document URLhttps://login.microsoftonline.com/[tenantID]/.well-known/openid-configuration
 13.OpenID Connect -> Client ID「アプリケーションID」
 14.OpenID Connect -> Client secret「シークレットキー」

Migrating Spotfire Server 14 + PostgreSQL Data to a New Server

Importing Spotfire Database on the New Server

  1. Create Database and Role:
    • Launch PostgreSQL (psql) as the postgres user.
    • Execute the following commands:
      • CREATE ROLE spotfire LOGIN CREATEDB PASSWORD 'yourPassword';
      • CREATE DATABASE spotfire_server OWNER spotfire;
  2. Import Data:
    • Use the command below to import data into the spotfire_server database:psql -U spotfire -d spotfire_server -f spotfire14.pgsql > import_spotfire_server.log 2>&1

Importing Spotfire ActionLog Database

  1. Create ActionLog Database and Role:
    • Again, use PostgreSQL (psql) as the postgres user.
    • Execute these commands:
      • CREATE ROLE spotfire_actionlog LOGIN CREATEDB PASSWORD 'yourPassword';
      • CREATE DATABASE spotfire_server_actionlog OWNER spotfire_actionlog;
  2. Import ActionLog Data:
    • To import data into spotfire_server_actionlog, use:psql -U spotfire_actionlog -d spotfire_server_actionlog -f spotfire_actionlog.pgsql > import_spotfire_server_actionlog.log 2>&1

Handling Errors

In case of any operation errors, follow these steps to delete the spotfire_server_actionlog database and the spotfire_server user:

  1. Delete Database and User:
    • DROP DATABASE spotfire_server_actionlog;
    • Then, check for sequences and views linked to the spotfire_server_actionlog database:
      • Sequences:SELECT sequence_name FROM information_schema.sequences WHERE sequence_catalog = 'spotfire_server_actionlog' AND sequence_schema = 'public';
      • Views:SELECT table_name FROM information_schema.views WHERE table_catalog = 'spotfire_server_actionlog' AND table_schema = 'public';
    • Revoke all privileges and drop the role:
      • REVOKE ALL PRIVILEGES ON SCHEMA public FROM spotfire_actionlog;
      • DROP ROLE spotfire_actionlog;

探索RAID技术

RAID 5

  • 硬盘数量:至少需要3个硬盘。
  • 奇偶校验信息:在 RAID 5 中,奇偶校验信息分布在所有硬盘上。对于阵列中的每个数据块,其奇偶校验块存储在不同的硬盘上。这意味着阵列可以承受任意单个硬盘的故障。

RAID 6

  • 硬盘数量:至少需要4个硬盘。
  • 奇偶校验信息:RAID 6 使用两份独立的奇偶校验信息,同样分布在所有硬盘上。这使得 RAID 6 阵列可以承受任意两个硬盘的同时故障。

数据和奇偶校验分布:在这两种类型的 RAID 配置中,数据块和奇偶校验块分布在所有硬盘上,而不是单独存储在特定的硬盘上。

容错性和效率:RAID 5 提供了较高的存储效率(大约为硬盘总容量的 2/3),而 RAID 6 提供了更高的容错性,但以降低存储效率(大约为硬盘总容量的 1/2)为代价。

RAID 0

  • 硬盘数量:至少需要2个硬盘。
  • 数据存储:在 RAID 0 中,数据被分成多个块(striping),然后平均分布在所有硬盘上。
  • 存储效率:RAID 0 提供了100%的存储效率,因为所有硬盘的全部容量都被用于存储数据。
  • 容错性:RAID 0 不提供任何容错性。如果任何一个硬盘故障,整个阵列的数据都会丢失。
  • 性能:RAID 0 通常提供最高的读写性能,因为数据被平行地分布在多个硬盘上。

RAID 1

  • 硬盘数量:至少需要2个硬盘。
  • 数据存储:在 RAID 1 中,数据在两个硬盘上被镜像存储,即每个硬盘都有一份相同的数据副本。
  • 存储效率:RAID 1 的存储效率约为50%,因为每个硬盘的一半容量用于存储数据的副本。
  • 容错性:RAID 1 提供很高的容错性,因为每个硬盘都有数据的完整副本。一个硬盘故障时,数据仍然安全。

RAID 10(也称为 RAID 1+0)

  • 硬盘数量:至少需要4个硬盘。
  • 数据存储:RAID 10 是 RAID 0 和 RAID 1 的组合。首先,数据在两个硬盘上被镜像(RAID 1),然后这些镜像集合又被分条存储(RAID 0)。
  • 存储效率:RAID 10 的存储效率约为50%,因为它将一半的存储空间用于数据镜像。
  • 容错性:RAID 10 提供很高的容错性和良好的性能。它可以承受至少一个硬盘的故障,有时甚至能承受两个硬盘的故障(只要它们不是同一个镜像对中的硬盘)。

RAID 2

  • 特点:RAID 2 使用了位级别的分条(striping),并且使用汉明码进行错误校正。
  • 弱点:这种类型的 RAID 需要大量的硬盘来存储错误校正代码,并且它的复杂性使得它在成本和效率方面不具竞争力。现代硬盘通常已经内置了错误校正功能,使得 RAID 2 变得多余。

RAID 3

  • 特点:RAID 3 使用字节级别的分条,并有一个专用硬盘用于存储奇偶校验信息。
  • 弱点:由于所有读写操作都必须包括奇偶校验硬盘,这限制了其性能。随着技术发展,其他如 RAID 5 的方案以更高的灵活性和效率提供了类似的功能。

RAID 4

  • 特点:与 RAID 3 类似,但使用块级别的分条。它也有一个专用硬盘用于存储奇偶校验信息。
  • 弱点:RAID 4 的主要限制是写入性能,因为所有写入操作都必须更新奇偶校验硬盘。RAID 5 提供了类似的保护,但以更优的写入性能分布了奇偶校验负担。

按存储效率排序(高到低)

  1. RAID 5:提供最高的存储效率。如果使用N个硬盘,存储效率约为 (N-1)/N,因为只有一个硬盘的空间用于奇偶校验数据。
  2. RAID 10:存储效率较低,大约为 50%,因为数据被镜像存储在两个不同的硬盘上。
  3. RAID 6:存储效率最低。如果使用N个硬盘,存储效率约为 (N-2)/N,因为有两个硬盘的空间被用于奇偶校验数据。

按速度排序(高到低)

  1. RAID 10:通常提供最高的读写速度。由于数据镜像和分条,它兼顾了性能和冗余。
  2. RAID 5:提供良好的读速度,但写速度由于奇偶校验计算而受到影响。它在读取操作中表现更优,因为可以从多个硬盘并行读取。
  3. RAID 6:读速度与 RAID 5 相似,但写速度由于额外的奇偶校验计算而更慢。RAID 6的写性能受到双重奇偶校验的影响。

Setting Up a Private VPN with Ngrok + OpenVPN in a Shared Network Environment

In scenarios like community-free networks where router access for port forwarding is not available, setting up a private VPN can be achieved using Ngrok and OpenVPN.

Install PiVPN and Choose OpenVPN (with TCP):

   sudo apt update -y && sudo apt upgrade -y
   curl -L https://install.pivpn.io | bash
  • Choose OpenVPN (not WireGuard, as it only supports UDP).
  • Set a local port, e.g., 11111.
  • Choose DNS, e.g., Google.
  • Select TCP.

Register and Install Ngrok:

   wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz
   sudo tar -xvzf ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin
   ngrok config add-authtoken [yourToken]
  • Output will confirm auth-token is saved.

Map the Local Port with Ngrok:

   ngrok tcp 11111
  • Note down the output showing the session status and the forwarding TCP address (e.g., tcp://0.tcp.jp.ngrok.io:[remotedPort]).

Edit the .ovpn File Created by pivpn add:

  • Reflect the 0.tcp.jp.ngrok.io:[remotedPort] information in the file.
  • Note: With the free version of Ngrok, the [remotedPort] changes with each restart.

Now, You Should Be Able to Access the Internal Network Using OpenVPN.

Setting Up a Boot Startup Task File:

Create an Auto-start Task:

   crontab -e
  • Add the following line to start Ngrok with the system:
    @reboot nohup ngrok tcp 11111 > /path/to/ngrok.log 2>&1

Or you can make a daemon:

cd /etc/systemd/system
sudo touch ngrok.service
sudo chmod 644 ngrok.service

ngrok.service:

[Unit]
Description=Ngrok Service
After=network.target

[Service]
ExecStart=/home/username/dev/ngrok.sh > /tmp/ngrok.log 2>&1
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=multi-user.target

ngrok.sh(make it executable):

#!/bin/bash
/usr/local/bin/ngrok config add-authtoken [yourToken]
/usr/local/bin/ngrok tcp [yourLocalPort]

then,

sudo systemctl daemon-reload
sudo systemctl restart ngrok.service

You can get the information of that randomized port used by ngrok:

curl http://127.0.0.1:4040/api/tunnels | jq '.tunnels[] | .public_url'

use OpenVPN in Linux as client side:

sudo openvpn --config [yourName].ovpn --connect-retry 0

Dealing with Frequently Changing Public IPs: No-IP DUC Script Setup

For situations where the public IP is constantly changing, install a background script using No-IP’s service:

  1. Install No-IP DUC Client:
   cd /usr/local/src
   tar xzf noip-duc-linux.tar.gz
   cd noip-2.1.9-1
   sudo make
   sudo make install
  1. Create and Configure the No-IP DUC Client:
   sudo /usr/local/bin/noip2 -C
  • You will be prompted to enter your No-IP username, password, and hostnames you wish to update.
  1. Run the No-IP DUC Client:
   sudo /usr/local/bin/noip2
  1. Check the No-IP DUC Client Status:
   sudo /usr/local/bin/noip2 -S
  1. Set Up Automatic Startup:
  • Edit the crontab:
    sudo crontab -e
  • Add the following line for auto-start:
    @reboot /usr/local/bin/noip2

Android Screen Mirroring to Ubuntu

Need to choose File Transfer/Android Auto

  • Prepare Android Device:
  • Enable ‘USB debugging’: Settings > About phone > Tap ‘Build number’ 7 times > Back > Developer options > USB debugging.
  • Enable ‘USB debugging (Security settings)’.
  • Setup on Ubuntu:
  • Install ADB: sudo apt install adb -y
  • Install Scrcpy: sudo apt install scrcpy -y
  • Connect Device:
  • Use USB to connect Android to Ubuntu.
  • Check connection: adb devices
  • Restart ADB if needed:
    • adb kill-server
    • adb start-server
  • Start Mirroring:
  • Command: scrcpy --bit-rate 2M --max-size 800
  • Troubleshooting:
  • Restart the phone if issues arise.

Configuring Spotfire Server to Access the Internet via a Proxy Server

  1. Navigate to Spotfire Server Installation Path:
    • Go to: C:\tibco\tss\12.0.8\tomcat\bin
    • Execute Command: tomcat9.exe //ES//Tss1208
  2. Java Configuration:
    • Tab: Java
    • Initial Memory Pool: 4096 MB
    • Maximum Memory Pool: 4096 MB
  3. Setting Java Options for Proxy Configuration:
    • -Dhttp.proxyHost=[HTTP Proxy Address]
    • -Dhttp.proxyPort=[HTTP Proxy Port]
    • -Dhttps.proxyHost=[HTTPS Proxy Address]
    • -Dhttps.proxyPort=[HTTPS Proxy Port]
  4. Restart Spotfire Server Service:
    • Stop and restart the Spotfire Server service for changes to take effect.

For Linux-based Spotfire server, just edit setenv.sh

通过 WordPress.com 设计一个这样的站点
从这里开始