目的と前提
ノーコードツールのPleasanterへのアクセスをapache2で設定するための自分用のメモです。
webサーバは、Pleasanter以外にも使っているので、最終的にはベースURLを指定してPleasanterを使うようにします。
ubuntu serverにPleasanterのインストールは終了している前提です。
Pleasanterについては、こちら↓↓
主な内容
- 足がかりになりそうな公式コンテンツ
- 共通事項
- ベースURLを指定しないパターン
- ベースURLを指定するパターン
足がかりになりそうな公式ドキュメント
chatGPTを使いながらいろいろやってみたが、よくよく調べたらそれなりの公式ドキュメントがあったので、こちらを見た方が良いかも…
ユーザマニュアル↓↓
apacheでのインストール↓↓
ベースURLの変更↓↓
共通事項
【必要なモジュールの有効化】
今回の設定で使うモジュールをあらかじめ有効化しておく
sudo a2enmod proxy proxy_http headers
sudo systemctl restart apache2
【設定ファイルの文法エラーチェック】
設定ファイルを有効化した後、うまくリロードできないときなどのチェック方法
sudo apache2ctl configtest
ベースURLを指定しないパターン
インストールに関する公式ドキュメントでは、nginxを使用する方法の記載があり、nginxの設定内容は次のとおり。
server {
listen 80;
server_name 192.168.1.100;
client_max_body_size 100M;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
これをapache用に書き換えると次のとおり。(ファイル名は任意)
<VirtualHost *:80>
ServerName 192.168.1.100
# クライアントの最大アップロードサイズ
LimitRequestBody 104857600
ProxyPreserveHost On
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
<Proxy *>
Require all granted
</Proxy>
</VirtualHost>
設定の有効化
sudo a2ensite my_site
sudo systemctl reload apache2
ベースURLを指定するパターン
webサーバはほかにも使うので、http://www.domain.com
でアクセスした際には、普通に/var/www/htmlに接続し、http://www.domain.com/pleasanger
でアクセスした時にはPleasanterに接続する場合。
【Pleasanterの起動設定】
/etc/systemd/system/pleasanter.service
に次のように内容追加
追加前
[Service]
ExecStart = /root/dotnet/dotnet Implem.Pleasanter.dll
追加後
[Service]
ExecStart = /root/dotnet/dotnet Implem.Pleasanter.dll --pathBase=/pleasanter
【パラメータファイルService.jsonの設定】
デフォルト設定でのインストールだと/web/pleasanter/Implem.Pleasanter/App_Data/Parameters
あたりにファイルあり。
Service.jsonの「AbsoluteUri」を次のように設定(デフォルト設定はnull
)
"AbsoluteUri": "http://localhost/pleasanter"
【apacheの設定】
<VirtualHost *:80>
ServerName 192.168.1.100
# 通常のWebサイトのルートディレクトリ
DocumentRoot /var/www/html
<Directory /var/www/html>
Require all granted
</Directory>
# /pleasanter のパスだけをリバースプロキシ
ProxyPreserveHost On
ProxyPass /pleasanter http://localhost:5000/pleasanter
ProxyPassReverse /pleasanter http://localhost:5000/pleasanter
<Location /pleasanter>
Require all granted
# X-Forwarded-For や X-Forwarded-Proto を追加
RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
</Location>
</VirtualHost>
【apacheとPleasanterの再起動】
sudo systemctl restart apache2
sudo systemctl restart pleasanter