# HTTP Configuration

To create a custom HTTP configuration, use the following code inside `declareConfiguration` of your GreenApp:

```java
int port = 8000;
builder.useHTTP1xServer(port);
```

You can add more configurations by appending them to the last configuration:

```java
int port = 8000;
builder.useHTTP1xServer(port)
        .useInsecureServer(); //example adding insecure server (no TLS)
```

## Configurations

### setHost(String host)

Specify a custom host address for the server.&#x20;

Support "\*" for subnets is enabled, for example "10.\*.\*.\*"

```java
builder.useHTTP1xServer(port)
        .setHost("127.0.0.1");
```

### useInsecureServer()

Disable TLS (HTTPS) for this server.

```java
builder.useHTTP1xServer(port)
        .useInsecureServer();
```

### setTLS(TLSCertificates tlsCertificates)

Set a custom TLS certificate object for HTTPS. See [here](/greenlightning/chapter-2-configuration/tls-certificates.md) for more information about default TLS certificates.

```java
builder.useHTTP1xServer(port)
        .setTLS(new TLSCertificate() {
                    ...
        }); 
```

### setClientAuthRequired(boolean b)

Determines if the client requires correct certificates to be allowed to connect to server.

```java
builder.useHTTP1xServer(port)        
        .setClientAuthRequired(true);
```

### setConcurrentChannelsPerDecryptUnit(int i)

The number of simultaneous stream of decryption for TLS.

```java
builder.useHTTP1xServer(port)
        .setConcurrentChannelsPerDecryptUnit(4);
```

### setConcurrentChannelsPerEncryptUnit(int i)

The number of simultaneous stream of encryption for TLS.

```java
builder.useHTTP1xServer(port)
        .setConcurrentChannelsPerEncryptUnit(4);
```

### setDecryptionUnitsPerTrack(int i)

The number of decryption unit required per track. Adjust this higher if e.g. users are sending large files per track.

```java
builder.useHTTP1xServer(port)
        .setDecryptionUnitsPerTrack(4);
```

### setEncryptionUnitsPerTrack(int i)

The number of encryption unit required per track. Adjust this higher if more encrypted content is required.

```java
builder.useHTTP1xServer(port)
        .setEncryptionUnitsPerTrack(4);
```

### setMaxResponseSize(int i)

The largest response size allowed (in bytes).

```java
builder.useHTTP1xServer(port)
        .setMaxResponseSize(1 << 20); //1 MB
```

### setServiceName(String name)

Updates the telemetry graph for debugging purposes.

```java
builder.useHTTP1xServer(port)
        .setServiceName("TestingServer");
```

### setDefaultPath(String path)

Set the default relative file path (not folder!) to be served by default (i.e. user connects to '<http://localhost/>');

```java
builder.useHTTP1xServer(port)
        .setDefaultPath("site.html");
```

### logTraffic(boolean b)

Determines if all requests AND responses should be logged.

```java
builder.useHTTP1xServer(port)    
    .logTraffic(true);
```

### setTracks(int t)

The number of parallel tracks for multicore performance.

```java
builder.useHTTP1xServer(port)
        .setTracks(4);
```

### setMaxConnectionBits(int i)

The number of max connection bits. For example, 12 would be 1 << 12 = 4096 total connections.

```java
builder.useHTTP1xServer(port)
        .setMaxConnectionBits(12);
```

### setMinConnections(int i) <a href="#setmaxconnectionbits-int-i" id="setmaxconnectionbits-int-i"></a>

The number of maximum users that can be reasonable expected. It will be rounded down or up if necessary to be a power of 2.

```java
builder.useHTTP1xServer(port)        
        .setMinConnections(1000);
```

​<br>


---

# 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://oci-pronghorn.gitbook.io/greenlightning/chapter-2-configuration/http-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.
