# 웹 Access 로그

이 시나리오는 클라이언트(Web Server)에서 생성된 웹 액세스 로그를  [PLURA Log Collector 서버](https://docs.plura.io/ko/agents/siem/plc)로 전송하는 방법을 설명합니다.

PLURA Log Collector 서버를 사용하면 클라이언트에서 별도의 암호화 또는 압축 없이 `syslog`를 통해 로그를 전송할 수 있어, CPU와 메모리 등 시스템 리소스 사용량을 최소화할 수 있습니다.

<figure><img src="https://qubitsec.github.io/docs/images/Additianal/logcol/1.png" alt=""><figcaption></figcaption></figure>

***

### 1. 클라이언트 설정: Apache Httpd 웹 접속 로그 생성 <a href="#id-1" id="id-1"></a>

* **환경**: CentOS 7 (64비트), Rsyslog 8.24.0-57.el7\_9.1
* Apache 웹서버에서 생성된 접속 로그를 `rsyslog`를 통해 PLURA Log Collector 서버로 전송합니다.

**1-1.** Rsyslog 설정 파일 생성 및 수정

Rsyslog 설정 파일을 생성하여 원격 로그 수집 서버로 로그를 전송하도록 설정합니다.

```bash
vi /etc/rsyslog.d/80-httpd-remote.conf
```

```
 #variables required for non-syslog log file forwarding – plura weblog
 #edit on your location

 input(type=”imfile”
 File=”/var/log/plura/weblog.log”
 Tag=”httpd”
 Severity=”info”
 Facility=”local7″)

 ###### Creates a template for each log file in the Logentries UI
 ### logic to apply the relevant templates to the different log files

 if $programname == ‘httpd’ then @PLURA_Log_Collector_Server:514 #UDP
 :programname, isequal, “httpd” stop
```

* **PLURA V5 웹 로그 경로**: `/var/log/plura/weblog.log`

{% hint style="warning" %}
**주의**: PLURA 웹로그 수집이 **OFF** 상태여야 합니다.
{% endhint %}

**1-2.** Rsyslog 서비스 재시작

```bash
service rsyslog restart
```

**1-3.** 서버 연결 테스트 (디버깅)

```bash
nc -zu PLURA_Log_Collector_Server 514
```

```
 Connection to PLURA_Log_Collector_Server 514 port [udp/syslog] succeeded!
```

### 2. 서버 설정: Log Collector 서버 구성 <a href="#id-2" id="id-2"></a>

* **환경**: CentOS 7, Rsyslog 8.2010.0
* 클라이언트에서 전송한 `syslog` 로그를 수집하기 위한 PLURA Log Collector 서버를 설정합니다.

**2-1.** PLURA Log Collector 서버 설치

> <https://docs.plura.io/ko/agents/siem/plc>

**2-2.** 방화벽 설정: syslog 포트 열기

```bash
firewall-cmd –add-port 514/udp
```

```bash
firewall-cmd –reload
```

**2-3.** Rsyslog 수신 설정 파일 수정 (`77-plura.conf`)

```bash
vi /etc/rsyslog.d/77-plura.conf
```

```
 $template CEETemplate, “%msg:2:$:%\n”

 # Provides UDP syslog reception
 $ModLoad imudp
 $UDPServerRun 514
```

**2-4.** Rsyslog 로그 파일 경로 설정 (`99-plura.conf`)

```bash
vi /etc/rsyslog.d/99-plura.conf
```

```
 $template DynaFile, “/var/log/plura/weblog-%FROMHOST-IP%.log”
 *.* -?DynaFile;CEETemplate
```

**2-5.** Rsyslog 서비스 재시작

```bash
service rsyslog restart
```

**2-6.** 로그 수신 확인

```bash
ls -al /var/log/plura/
```

* `/var/log/plura/` 디렉터리에 로그 파일이 생성되어 있으면 로그 수집이 정상적으로 이루어지고 있는 것입니다.

**2-7.** Log Collector 서버 등록

* 경로: [시스템 > 시스템 관리](https://docs.plura.io/ko/function/common/system/management) **> 로그 취합 호스트(부모) 선택 > 수집 환경 선택**

<figure><img src="https://qubitsec.github.io/docs/images/Additianal/logcol/03.png" alt="" width="563"><figcaption></figcaption></figure>

### 참고 자료 <a href="#id-3" id="id-3"></a>

> <https://rsyslog.readthedocs.io/en/latest/configuration/modules/imfile.html>
