# Squidロギングオン

### 1. ForwardプロキシでSquidを使用する時、PLURA ロギング(logging)連動設定方法です。 <a href="#id-1" id="id-1"></a>

httpdと同様のロギング方法は下記の通りです。

{% hint style="info" %}

```
logformat httpd %>a %[ui %[un [%tl] “%rm %ru HTTP/%rv” %>Hs %<st “%{Referer}>h” “%{User-Agent}>h” %Ss:%Sh
access_log /var/log/squid/access.log httpd
```

{% endhint %}

### 2. jsonでPLURA V5ロギング形式で保存する方法は下記の通りです。 <a href="#id-2" id="id-2"></a>

`# vi /etc/squid/squid.conf`

{% hint style="info" %}

```
 forwarded_for on
 acl has-xff req_header X-Forwarded-For ^(([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)|(\[([0-9a-f]+)?:([0-9a-f:]+)?:([0-9a-f]+|0-9\.]+)?\]))

 # add logging for PLURA
 logformat combinedjson {“Remote-addr”: “%>a”, “X-forwarded-for”: “%{X-Forwarded-For}>h”, “Request-date”: “%tl”, “Method”: “%rm”, “Request”: “%rm %rp HTTP/%rv”, “Host”: “%>rd”, “Uri”: “%ru”, “Resp-Content-Type”: “%mt”, “Refere”: “%{Referer}>h”, “User-Agent”: “%{User-Agent}>h”, “Status”: “%>Hs”, “Resp-Content-Length”: “%<st”, “ProxyStatus”: “%Ss:%Sh”}

 #access_log /var/log/squid/access.log combinedjson
 access_log stdio:/var/log/plura/weblog.log combinedjson !has-xff
 access_log stdio:/var/log/plura/weblog.log combinedjson has-xff
```

{% endhint %}

▶ Git source, <https://github.com/QubitSecurity/ModPlura/tree/main/squid>

### 3. Squidをウェブシステムとして認識させるコマンド <a href="#id-3" id="id-3"></a>

`# echo “ModPlura-squid” > /etc/modplura`

`# echo “0.0.1” >> /etc/modplura`

`# touch /etc/.modplura`

### 4. Squid accessログファイルに権限付与 <a href="#id-4" id="id-4"></a>

`# touch /var/log/plura/weblog.log`

`# chmod -R 766 /var/log/plura/weblog.log`

`# chcon -t squid_log_t /var/log/plura/weblog.log`

<br>

**PLURA > システム > システム管理**でリストのシステムを拡張すると、下記のように確認されます。

### 参考サイト <a href="#id-5" id="id-5"></a>

<http://www.squid-cache.org/Doc/config/logformat/>

<https://bit.ly/36DjfZ3>

<https://bit.ly/3hzt6Fw>

<https://gist.github.com/kosho/82546a86140ad67c866e8197d730c53c>

### 参考サイト XFF <a href="#id-6" id="id-6"></a>

[https://gist.github.com/alvarow/fa409edc70aeb4cf89bbc83c1c78f39](https://gist.github.com/alvarow/fa409edc70aeb4cf89bbc83c1c78f392)
