Browsers reach a self-hosted AnythingLLM Docker server over plain HTTP on port 3001 by default, which leaves sign-ins, chats and uploaded documents unencrypted on the network. An Nginx reverse proxy on the same Linux host can accept HTTPS for the server's hostname and pass each request to AnythingLLM, including the agent connections behind @agent chats.

Page loads and streamed chat replies are ordinary HTTP requests, but an @agent chat switches to a WebSocket at /api/agent-invocation/ for the rest of the session. Nginx forwards that protocol switch only when the proxy sets the Upgrade and Connection headers itself, and it closes a quiet proxied connection after 60 seconds while AnythingLLM can wait up to five minutes for the next agent message. Without both settings the interface loads over HTTPS, yet agent sessions fail or drop.

An AnythingLLM container created with the published Docker command must already be running on an Ubuntu or Debian server, with a chat provider and agent model answering in a workspace. Its hostname must resolve to the server, and a local certificate authority created with OpenSSL issues the server certificate, so every client browser needs that CA's public certificate in its trust store. A site open to the internet normally uses a certificate from a publicly trusted authority instead. After HTTPS works, AnythingLLM's port 3001 moves to the loopback address so that Nginx becomes the only network entrance.

Steps to configure an Nginx reverse proxy for AnythingLLM:

  1. Refresh the package index on the AnythingLLM server.
    $ sudo apt-get update
  2. Install the Nginx web server package.
    $ sudo apt-get install nginx

    Ubuntu and Debian start Nginx after installation with a default site on port 80. The AnythingLLM site added below listens only on port 443, so the default site can stay in place.

  3. Create a root-only directory for the AnythingLLM TLS files.
    $ sudo install -d -m 700 /etc/nginx/tls
  4. Generate the server private key and certificate signing request in the directory that contains the local-ca folder.

    The key is written without a passphrase so that Nginx can start unattended. Anyone who reads it can impersonate the server, so it stays inside the root-only directory and never leaves the server.

    $ sudo openssl req -new -newkey rsa:2048 -nodes \
      -keyout /etc/nginx/tls/anythingllm.key \
      -subj '/CN=anythingllm.example.test' > anythingllm.csr

    anythingllm.example.test stands in for the DNS name that clients use for AnythingLLM, in every command and file where it appears. Your own shell writes the request file, so it stays readable for signing without root; it holds only public data. An -out option would create it as a root-only file instead.

  5. Create a file named anythingllm.ext beside the local-ca folder using your text editor.
    [server_cert]
    basicConstraints = critical, CA:FALSE
    keyUsage = critical, digitalSignature, keyEncipherment
    extendedKeyUsage = serverAuth
    subjectAltName = DNS:anythingllm.example.test
    subjectKeyIdentifier = hash
    authorityKeyIdentifier = keyid,issuer

    Browsers match the hostname against subjectAltName, not the common name. A server reached by more than one name lists each one, separated by commas, such as DNS:anythingllm.example.test,DNS:ai.example.test.

  6. Sign the request with the local CA to issue the server certificate.
    $ openssl x509 -req -in anythingllm.csr \
      -CA local-ca/certs/ca.crt -CAkey local-ca/private/ca.key \
      -CAcreateserial -out anythingllm.crt -days 397 -sha256 \
      -extfile anythingllm.ext -extensions server_cert
    Certificate request self-signature ok
    subject=CN=anythingllm.example.test
    Enter pass phrase for local-ca/private/ca.key:

    The passphrase protects the CA key created with the local CA. -CAcreateserial writes ca.srl beside the CA certificate to track issued serial numbers.
    Related: How to sign a CSR with a local CA using OpenSSL

  7. Verify that the new certificate chains to the local CA and covers the AnythingLLM hostname.
    $ openssl verify -CAfile local-ca/certs/ca.crt \
      -purpose sslserver -verify_hostname anythingllm.example.test \
      anythingllm.crt
    anythingllm.crt: OK

    A hostname mismatch or a certificate signed by another CA stops with an error here instead of OK.
    Related: How to verify a certificate chain using OpenSSL

  8. Install the signed certificate beside its private key.
    $ sudo install -m 644 anythingllm.crt /etc/nginx/tls/anythingllm.crt
  9. Create the AnythingLLM proxy configuration with sudoedit.
    $ sudoedit /etc/nginx/conf.d/anythingllm.conf
    /etc/nginx/conf.d/anythingllm.conf
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }
     
    server {
        listen 443 ssl;
        server_name anythingllm.example.test;
     
        ssl_certificate     /etc/nginx/tls/anythingllm.crt;
        ssl_certificate_key /etc/nginx/tls/anythingllm.key;
     
        location / {
            proxy_pass http://127.0.0.1:3001;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
     
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-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;
            proxy_read_timeout 600s;
        }
    }

    Files in /etc/nginx/conf.d/ load inside Nginx's http block, where map belongs. The map sends Connection: upgrade when the browser asks for a WebSocket and Connection: close otherwise; the keepalive-style Connection "" used for ordinary backends does not forward the upgrade. proxy_pass has no URI part, so request paths reach AnythingLLM unchanged. proxy_buffering off passes streamed chat replies to the browser as they are generated, and the 600-second read timeout outlasts AnythingLLM's five-minute wait for the next agent message. Nginx rejects request bodies over 1 MB by default with 413 Request Entity Too Large, so larger document uploads depend on a higher client_max_body_size in this server block.

  10. Test the Nginx configuration before applying it.
    $ sudo nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

    An error names the file and line to correct. A failed test leaves the running configuration untouched as long as Nginx is not reloaded.
    Related: How to test Nginx configuration

  11. Reload Nginx to start serving the HTTPS site.
    $ sudo systemctl reload nginx

    A reload keeps existing connections while workers pick up the new configuration.
    Related: How to manage the Nginx service

  12. Request AnythingLLM's health endpoint through Nginx over HTTPS with the local CA certificate.
    $ curl --cacert local-ca/certs/ca.crt https://anythingllm.example.test/api/ping
    {"online":true}

    The reply comes from AnythingLLM through the proxy, and --cacert makes curl verify the certificate against the local CA instead of skipping the check. A curl certificate error points to the hostname or CA, while 502 Bad Gateway means Nginx cannot reach port 3001.

  13. Record the exact local image used by the existing AnythingLLM container.
    $ IMAGE="$(docker inspect --format '{{.Image}}' anythingllm)"

    The remaining commands run in this same shell. Reusing the image ID keeps the software version unchanged while only the port mapping changes, so docker ps later lists the image as a short ID instead of mintplexlabs/anythingllm:1.19.0.

  14. Stop the existing AnythingLLM container.

    This interrupts AnythingLLM, including chats in progress. The stopped container is kept for recovery, and its persistent data stays in the mounted storage directory.

    $ docker stop anythingllm
    anythingllm
  15. Rename the stopped container to retain the original deployment.
    $ docker rename anythingllm anythingllm-before-proxy

    Recovery consists of stopping and removing the replacement, renaming this container back to anythingllm, then starting it. Both containers use the same storage, so they must never run at the same time.

  16. Recreate the AnythingLLM container with its web port bound only to the loopback address.
    $ docker run -d \
      --name anythingllm \
      --cpus 2 --memory 4g \
      -p 127.0.0.1:3001:3001 \
      -v "$HOME/anythingllm:/app/server/storage" \
      -v "$HOME/anythingllm/.env:/app/server/.env" \
      -e STORAGE_DIR="/app/server/storage" \
      "$IMAGE"

    127.0.0.1:3001:3001 publishes the port to processes on this server only, which includes Nginx. Every other option must match the original container, including its storage mounts, environment variables and any --add-host or network option a provider connection relies on.

    Later recreations of this container, including an update to a newer image, must keep -p 127.0.0.1:3001:3001. The published -p 3001:3001 form exposes plain HTTP on every interface again.
    Related: How to update AnythingLLM in Docker

  17. Confirm that port 3001 now listens only on the loopback address.
    $ ss -ltn 'sport = :3001'
    State  Recv-Q Send-Q Local Address:Port Peer Address:Port
    LISTEN 0      4096       127.0.0.1:3001      0.0.0.0:*

    A 0.0.0.0:3001 or [::]:3001 line means the replacement still publishes AnythingLLM to the network.

  18. Open https://anythingllm.example.test in a browser that trusts the local CA.

    Each client imports only the public local-ca/certs/ca.crt into its browser or operating system trust store. The CA private key stays on the machine that signs certificates.

  19. Confirm that AnythingLLM loads over HTTPS without a certificate warning.

    A Not secure label or a privacy error page means the browser does not trust the local CA or the hostname is missing from the certificate.

  20. Open your workspace from the AnythingLLM sidebar.

    The pictures use a workspace named Guide workspace.

  21. Send the following agent request from the workspace chat.
    @agent What is 17 multiplied by 23? Reply in one sentence.

    The @agent prefix starts an agent session, and the browser opens its WebSocket through Nginx as soon as the request is sent.

  22. Send /exit after the agent answers to end the agent session.

    After answering, AnythingLLM keeps the agent session open for up to five minutes while it waits for another message. The answer can take longer to appear on a small CPU model.

  23. Expand the Thoughts entry that appears below /exit.

    The @ agent button returns beside Tools when the session closes.

  24. Confirm that the expanded entry shows the Agent session complete status.

    The session closed normally after the agent's answer. A connection error in place of the answer, or a session that ends by itself while idle, points to the WebSocket settings in the Nginx configuration.

  25. Check the Nginx access log for the agent WebSocket connection.
    $ sudo grep agent-invocation /var/log/nginx/access.log
    192.0.2.10 - - [14/Nov/2026:14:08:55 +0800] "GET /api/agent-invocation/092a14a6-4359-47ca-8c30-80fa735ca994 HTTP/1.1" 101 3246 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36"

    Status 101 records the switch to a WebSocket through Nginx; the line is written when the connection closes at the end of the session. Any other status, or no matching line, means the WebSocket did not pass through Nginx, most often because the Upgrade and Connection headers are missing from the proxy configuration.

Share this guide