Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: nginx instructions #3365

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions docs/guides/deploying/deploying_nginx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Deploy with nginx

nginx is a popular web server that can be used as a reverse proxy for web applications. This guide will show you how to deploy marimo behind an nginx reverse proxy.

## Prerequisites

- A marimo notebook or app that you want to deploy
- nginx installed on your server
- Basic understanding of nginx configuration

## Configuration

Create a new configuration file in `/etc/nginx/conf.d/` (e.g., `marimo.conf`):

```nginx
server {
server_name your-domain.com;

location / {
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_pass http://127.0.0.1:2718;

# Required for WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 600;
}

# Optional: Serve static files
location /static/ {
alias /path/to/your/static/files/;
}
}
```

## Breaking it down

- `server_name`: Replace with your domain name
- `proxy_pass`: Points to your marimo application (default port is 2718)
- WebSocket support: The following lines are required for marimo to function properly:

```nginx
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
```

- `proxy_read_timeout`: Increased to 600 seconds to handle long-running operations

## Running your application

1. Start your marimo application:

```bash
marimo run app.py --host 127.0.0.1 --port 2718
```

2. Test your nginx configuration:

```bash
nginx -t
```

3. Reload nginx to apply changes:

```bash
nginx -s reload
```

Your marimo application should now be accessible at your domain.

## SSL/HTTPS

For production deployments, it's recommended to use HTTPS. You can use [Certbot](https://certbot.eff.org/) to automatically configure SSL with Let's Encrypt certificates.

## Common Issues

### Kernel Not Found

If you see a "kernel not found" error, ensure that:

1. WebSocket support is properly configured in your nginx configuration
2. The proxy headers are correctly set
3. Your marimo application is running and accessible at the specified proxy_pass address
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ nav:
- Ploomber: guides/deploying/deploying_ploomber.md
- Public gallery: guides/deploying/deploying_public_gallery.md
- Railway: guides/deploying/deploying_railway.md
- nginx: guides/deploying/deploying_nginx.md
- Prebuilt containers: guides/deploying/prebuilt_containers.md
- Programmatic: guides/deploying/programmatically.md
- Editor features:
Expand Down
Loading