メモ書きブログ

日々の覚書

Raspberry pi をプロキシー環境で設定してLDAPサーバーとして使う①

はじめに

Raspberry PIを使って、固定IPアドレスを指定したい都合で、 更にProxyを通したい。

OS選定

まずはRaspi imagerで書き込む。 このとき、余計なGUIがあると起動時間が遅いなど、あまり良いことが無い為、 書き込むOSをraspberry pi OS LITEにする。

IP固定

起動後は、sudo vi /etc/dhcpcd.confして、

interface eth0
noipv6
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.10
static domain_search=192.168.1.11

domain_serachは代替DNSなので、無ければ設定しなくていい。 ネットワークを再起動して、IPが固定できているか確認する。

sudo systemctl restart dhcpcd.service
ifconfig

aptのプロキシ設定

最初にインターネットを使いたいのはaptだろう。

sudo vi /etc/apt/apt.conf

apt.confに下記を追加する。

 Acquire::http::proxy "http://proxy.example.co.jp:8080/";
 Acquire::https::proxy "http://proxy.example.co.jp:8080/";
 Acquire::ftp::proxy "ftp://proxy.example.co.jp:9021/";
 Acquire::socks::proxy "socks://proxy.example.co.jp:1080/";

httpは8080で、ftpは9021である。socksは1080だと思う。

aptのサーバー設定

bullseyeのリリースが削除されているようなので、下記を参考にミラーに置き換える。 https://wakky.tech/raspberry-pi-4-repository-error/

時計も直しておく sudo date -s'22 Jun 2022 10:10'

エディタのインストール

最初に、sudo apt-get updateしてから、 sudo apt-get install emacs

.bashrc

wgetを使う場合は.bashrcに書いて環境変数にもプロキシを設定しておこう

export http_proxy=http://proxy.example.co.jp:8080/
export https_proxy=http://proxy.example.co.jp:8080/
export ftp_proxy=ftp://proxy.example.co.jp:9021/
export socks_proxy=socks://proxy.example.co.jp:1080/

# source .bashrc

openldapインストール

sudo apt-get install slapd ldap-utils

ついでにphpのwebuiもインストールしてみる

sudo apt-get install php php-cli php-fpm phpldapadmin nginx

nginxがうまく起動しない。。。

sudo netstat -plant | grep 80

すると、apache2がインストールされていて、0.0.0.0:80を占有している

sudo systemctl stop apache2 sudo systemctl start nginx

これだと502 になってしまう。tail -f /var/log/nginx/error.logしていると どうやらphpのアクセスが出来ないらしいので、、、

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

サーバブロックを書き換えてphpの設定を書き込む。

server {
 root /usr/share/phpldapadmin/htdocs;
 index index.php index.html;
 server_name localhost;
 location ~ \.php$ {
 fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
 fastcgi_index index.php;
 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
 include fastcgi_params;
 }
}

つづく