Why self-host Stable Diffusion WebUI on a VPS
Online image-generation services charge per image, limit the resolution and restrict content. By deploying Stable Diffusion WebUI on your own VPS, you get a complete web interface (txt2img, img2img, inpainting, upscaling) that runs continuously and stays accessible to your whole team. You install the checkpoints of your choice (SD 1.5, SDXL, fine-tuned models), you chain the extensions (ControlNet, ADetailer) and you generate as many images as your hardware allows. Note: generation is heavy — a GPU VPS offers decent render times, while a CPU VPS remains viable for small batches or tests, at the cost of minutes per image.
The concrete benefits of self-hosting
- Unlimited generation: no credit or monthly image quota.
- Total confidentiality of the prompts and produced visuals (useful for client mock-ups under NDA).
- Model freedom: add any checkpoint, LoRA or VAE by simply dropping in a file.
- Extensions at will: ControlNet, ADetailer, Regional Prompter installed in one click.
- Built-in REST API to plug generation into your own tools or a batch workflow.
- Predictable cost: a fixed VPS price rather than usage-based billing that skyrockets.
Hardware and software prerequisites
For a comfortable experience, aim for a GPU VPS (NVIDIA with at least 8 GB of VRAM for SDXL, 6 GB is enough for SD 1.5) accompanied by 16 GB of RAM and 4 vCPUs. On a CPU-only VPS, count on 8 to 16 GB of RAM minimum and accept renders of several minutes. Plan for 30 to 50 GB of disk just for the checkpoints (an SDXL model weighs ~6.5 GB). On the software side: Ubuntu 22.04 LTS, Python 3.10, git, Docker (recommended), the NVIDIA drivers + the NVIDIA Container Toolkit if you go through the GPU, and a domain name or subdomain (e.g. sd.mydomain.com) pointing to the VPS IP.
Step-by-step deployment
Prepare the VPS and the GPU
Connect via SSH, update the system with apt update && apt upgrade -y. On a GPU VPS, install the NVIDIA drivers and check with nvidia-smi, then install the NVIDIA Container Toolkit to expose the GPU to Docker.
Grab a ready-to-use Docker image
Rather than installing the Python dependencies by hand, start from a community image such as ghcr.io/abetlen/stable-diffusion-webui-docker. Create a docker-compose.yml file mounting a ./models volume and exposing port 7860, with the deploy.resources.reservations.devices directive for the GPU.
Drop in a checkpoint
Download a model (.safetensors) from your usual source into ./models/Stable-diffusion/. Start the stack with docker compose up -d then follow the startup via docker compose logs -f.
Secure access
The interface has no authentication by default. Launch WebUI with the argument --api --gradio-auth utilisateur:motdepasse or, better, place HTTP Basic authentication at the reverse proxy level.
Configure the reverse proxy and SSL
Install Nginx or Caddy. With Caddy, two lines are enough: sd.mydomain.com { reverse_proxy localhost:7860 } automatically generates a Let's Encrypt certificate. Increase proxy_read_timeout to 300s under Nginx, since renders can be long.
Validate and persist
Open https://sd.mydomain.com, launch a first txt2img generation. Check that the outputs/ folder is indeed on a persistent volume so nothing is lost when the container restarts.
On a VPS without a GPU, add the arguments --use-cpu all --no-half --precision full to avoid errors related to half precision, and favor SD 1.5 with a fast sampler (DPM++ 2M Karras, 20 steps) at 512x512. To exploit batching without blocking the interface, use the /sdapi/v1/txt2img API from a script and let WebUI process a queue overnight.