> For the complete documentation index, see [llms.txt](https://docs.fivemstats.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fivemstats.net/tgiann-fivem-stats-script/https.md).

# HTTPS

Make screenshots and videos load in the panel. Pick one of three ways.

The panel runs on HTTPS, so browsers only show files that also come over HTTPS. Without it the [Media](https://docs.fivemstats.net/panel/media.md) page shows **Needs HTTPS on the game server**, and uploads and ZIP downloads stop. Screenshots inside the game work either way.

## Which way?

| You have                      | Use                                                                                                       | What to do                              |
| ----------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------- |
| Only the server's IP          | **Automatic certificate** (the default)                                                                   | Open TCP port `80`, nothing else        |
| A domain                      | [**Cloudflare Tunnel**](https://docs.fivemstats.net/tgiann-fivem-stats-script/https/cloudflare-tunnel.md) | The easiest way: free, no ports to open |
| Your own certificate or nginx | **custom** or **off**                                                                                     | See the last two sections below         |

## Automatic certificate

This is the default (`tgiann_media_https "auto"`). The service gets a free Let's Encrypt certificate for your server's IP and renews it on its own.

1. Open TCP `80` and the media port, see [Ports and Firewall](https://docs.fivemstats.net/tgiann-fivem-stats-script/ports-and-firewall.md).
2. Restart the resource.
3. The console shows `https: certificate active for <ip>`. Done.

If the console shows `Let's Encrypt could not reach TCP port 80`, port 80 is still closed somewhere (your host's panel or DDoS filter). The service tries again every hour; restart the resource to try at once.

The server has several IPs and the wrong one is used? Set it: `set tgiann_media_public_ip "203.0.113.10"`.

## Your own certificate (custom)

```cfg
set tgiann_media_https "custom"
set tgiann_media_tls_cert "C:/certs/fullchain.pem"
set tgiann_media_tls_key "C:/certs/privkey.pem"
```

The files are read again every 6 hours, so a renewed certificate is picked up without a restart. Then enter the address the certificate is for in [Settings > Media storage > Public address](https://docs.fivemstats.net/panel/settings.md#media-storage), for example `https://media.yourserver.com:6174`.

## Your own proxy (off)

For nginx, Caddy or another proxy in front of the service:

```cfg
set tgiann_media_https "off"
set tgiann_media_host "127.0.0.1"
```

Point the proxy at `http://127.0.0.1:6174` and allow uploads up to 400 MB:

```nginx
server {
    listen 443 ssl;
    server_name media.yourserver.com;
    ssl_certificate     /etc/letsencrypt/live/media.yourserver.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/media.yourserver.com/privkey.pem;
    client_max_body_size 400m;

    location / {
        proxy_pass http://127.0.0.1:6174;
        proxy_set_header Host $host;
    }
}
```

Then enter `https://media.yourserver.com` in [Settings > Media storage > Public address](https://docs.fivemstats.net/panel/settings.md#media-storage).

## Check it

Open `http://<server-ip>:6174/health`. The `https` part shows `"state":"active"` when it works, or `"error"` with the reason.

{% hint style="info" %}
Test server on a home PC? Use `set tgiann_media_https "off"`. Behind a home router the automatic certificate cannot work and would break pictures in your own game.
{% endhint %}
