---
title: Run in production
project: OpenAuth
version: 1.0
section: guides
language: en
license: MIT
url: https://totaljs.es/docs/openauth/1-0/guides/production/
updated: 2026-11-19T09:22:02.490Z
---

# Run in production

> Prepare OpenAuth for a public server: HTTPS, the right address, release mode.

OpenAuth holds your provider secrets and hands out access tokens, so the server needs some care before users reach it.

## Set the primary access token

Do it before anything else. See [Protect the admin interface](../protect-admin/).

## Use HTTPS

Tokens, sign-in codes and profiles travel through OpenAuth. Put it behind a reverse proxy (for example Nginx or Caddy) that serves HTTPS, and let your apps and users use the `https://` address only.

## Pass the public address to OpenAuth

OpenAuth builds the sign-in address and the callback endpoint from the address of each request. Behind a reverse proxy, forward the original host and protocol, or providers reject the callback. With Nginx:

```nginx
location / {
    proxy_pass http://127.0.0.1:8000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
}
```

Then check that **Configure** in [Extensions](../extensions/) shows the `https://` callback endpoint, and that `POST /` answers with an `https://` sign-in address.

## Listen only on the local address

By default OpenAuth listens on all network interfaces. When the reverse proxy runs on the same server, make OpenAuth listen only on `127.0.0.1`. In `index.js`, change the line

```js
// options.ip = '127.0.0.1';
```

to

```js
options.ip = '127.0.0.1';
```

and restart OpenAuth. With Docker, publish the port only on the local address instead:

```bash
docker run -d --name openauth -p 127.0.0.1:8000:8000 -v openauth:/www openauth
```

## Start in release mode

`npm start` runs in debug mode. On a server, start OpenAuth in release mode:

```bash
node index.js 8000 --release
```

## Restrict the admin interface

Your apps need only `/`, `/login/`, `/oauth/` and `/sessions/`. If you can, allow `/setup/` and `/api/` only from your own network in the reverse proxy.

## One token per app

Give each app its own [app token](../app-tokens/), and remove the token of an app you retire.

## Back up

Copy the data folder on a schedule. See [Back up your data](../backups/).
