> For the complete documentation index, see [llms.txt](https://alphactyl.gitbook.io/alphactyl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alphactyl.gitbook.io/alphactyl/installation/webserver-configuration.md).

# Webserver Configuration

## Nginx Webserver Configuration

[Create ssl certificate using Certbot](/alphactyl/additional/creating-ssl-certificates.md)

### Nginx With SSL

Delete or disable the default config.

```
sudo mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.disabled
```

Create a configuration file for the app in `/etc/nginx/sites-enabled`

```
apt install nano
```

```
nano /etc/nginx/sites-enabled/AlphaCtyl.conf
```

Replace `<domain.com>` with your domain example.com and replace `<port>` with your Port. and paste the code then save and exit by clicking  `Ctrl + x` and `y` then `enter enter`

```properties
server {
    listen 80;
    listen [::]:80;
    server_name <domain>;

    # Redirect HTTP to HTTPS
    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name <domain>;

    ssl_certificate /etc/letsencrypt/live/<domain>/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/<domain>/privkey.pem;
    ssl_session_cache shared:SSL:10m;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers 'HIGH:!aNULL:!MD5:!ECDHE-RSA-AES128-SHA';

    # Location for your application
    location / {
        proxy_pass http://localhost:<port>/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }

    # Location for your /afk endpoint
    location /afk {
        proxy_pass http://localhost:<port>/afk;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }
}

```

Test your configuration.

```
sudo nginx -t
```

If there aren't any errors you can restart the configuration.

```
sudo nginx -s reload
```
