# Apache Web Server Configuration

This section describes how to configure **Apache Web Server (Apache2)** for use with the ONEWEB Platform.\
Apache acts as a **reverse proxy and web entry point**, handling client HTTP requests and forwarding application traffic to the ONEWEB runtime.

***

#### Configuration Overview

To configure Apache Web Server for ONEWEB, the following high‑level tasks are required:

1. Configure Apache as a **reverse proxy**
2. Configure and enable a **VirtualHost**
3. Enable required **Apache modules**
4. Configure the **listening port**
5. Verify application access via **context root**

Each step is described below.

***

Step 1: Configure Apache Reverse Proxy

Apache must be configured as a **reverse proxy** to forward client requests to the ONEWEB application server.

* Create or update a **VirtualHost configuration file**
* Copy the VirtualHost file into the appropriate Apache configuration directory

The following diagram illustrates the reverse proxy setup:

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FHQiz8DlGas3ZaG7edmRj%2Fimage.png?alt=media&#x26;token=1bfe9cf5-f092-4696-b3ec-f4c13fd84a9b" alt=""><figcaption></figcaption></figure>

***

#### Step 2: Enable and Disable VirtualHost

After configuring the VirtualHost, use Apache utilities to enable or disable the site.

**Disable a VirtualHost**

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2F6tqrpybdug6CHfFhFgxL%2Fimage.png?alt=media&#x26;token=d5df9e73-1c1f-4708-8515-d4c46ae8a029" alt=""><figcaption></figcaption></figure>

**Enable a VirtualHost**

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FCJtQmCH4Y1yNbtsAF7Gb%2Fimage.png?alt=media&#x26;token=fd038ff7-c8d5-4e76-ac38-187877d68878" alt=""><figcaption></figcaption></figure>

After enabling the site, restart Apache to apply the changes.

**Restart Apache**

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2F2ZkUzQ9HOjRJNaoB5s6z%2Fimage.png?alt=media&#x26;token=61f29854-f8f4-4848-821c-29411001f8f8" alt=""><figcaption></figcaption></figure>

***

#### Step 3: Enable Required Apache Modules

ONEWEB requires several Apache modules to support proxying, load balancing, and request handling.

Enable the required modules using the `a2enmod` utility:

```
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_ajp
sudo a2enmod rewrite
sudo a2enmod deflate
sudo a2enmod headers
sudo a2enmod proxy_balancer
sudo a2enmod proxy_connect
sudo a2enmod proxy_html
```

After enabling modules, restart Apache to ensure all modules are loaded.

***

#### Step 4: Configure Apache Listening Port

If a custom port is required, update Apache’s default listening port.

* Edit the Apache configuration file:
  * **`ports.conf`**
* Change the default port to the required value

The following example shows a port configuration change:

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2Fsp3M9fXaOhhX8HoV5d6N%2Fimage.png?alt=media&#x26;token=3c18a66b-1310-4340-9320-8748ec46d45c" alt=""><figcaption></figcaption></figure>

***

#### Step 5: Test Application Context Root

After completing the configuration:

* Access the application using the configured **context root**
* Verify that Apache successfully forwards requests to the ONEWEB application server

The following image illustrates a successful context root test:

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FvVdbDS9GVBrjeMfwkRKr%2Fimage.png?alt=media&#x26;token=78d27e90-40e2-42e0-91d4-39845c78cd49" alt=""><figcaption></figcaption></figure>

***

#### Configuration Checklist

Before proceeding, confirm that:

* Apache reverse proxy is configured
* VirtualHost is enabled
* Required modules are loaded
* Apache is listening on the correct port
* Application context root is accessible


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onewebstack.com/oneweb-platform-th/getting-started/platform-configuration/platform-components-overview-and-management/prepare-prerequisite-software/prepare-web-server/apache-web-server-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
