This action requires saving a cookie to remember the page's state. You can read more about that on the cookies page.

 

How to share stable diffusion on your network

Released on: 2023-08-29

The Automatic1111 webui for Stable Diffusion has a --share option to

use share=True for gradio and make the UI accessible through their site

If you don’t want to expose anything externally, but do want to share it on your local network, here’s one way to do it.

Updates

–listen

On recent versions of Automatic1111 and Forge, there is the --listen option that removes the need for a reverse proxy to expose the port. There are valid reasons why you might still want a reverse proxy, but for most people the --listen option will be better.

The advantage of --listen over a reverse proxy is fewer moving parts, and therefore fewer things:

  • to break.
  • to introduce potential security vulnerabilities.

You’ll still need to open up the appropriate port on your firewall.

I’ll leave this article up for those who might benefit from a reverse proxy.

NOTE: --listen is a misnomer for how the behaviour changes from default. Ie it’s already listening, it’s just changing the scope of the listening.

Table of contents

Steps

Install nginx

On linux, this is simply a matter of using your package manager to install the nginx pacakge. Eg on OpenSUSE, it’s

sudo zypper install nginx

On Windows, you’ll probably have success with the Windows version.

On MacOS, brew should get you what you need.

Create the vhost

While all of the distros that I have used nginx with put the nginx configuration in /etc/nginx; each distro tends to configure the nginx directory structure a little differently. Eg on ubuntu there is sites-available vs sites-enabled. While on OpenSUSE it’s vhosts.d where you’ll want to put the following config. In any case, take a look in /etc/nginx to see which is right for you.

You’ll need to stick the following configuration in which ever directory you determined above:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    location / {
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_pass http://localhost:7860;
    }
}

Reload nginx

sudo systemctl reload nginx

NOTE: To give users a seamless experience while site owners roll out configuration changes, nginx lets existing instances finish before killing them off. So when you make changes, you may not see the results immediately. This is a longer conversation, but for the purposes of sharing a service in your home, it probably doesn’t matter if you see an error from a broken connection. So you can speed up the process like this:

sudo systemctl stop nginx; sudo systemctl start nginx

Make sure that your firewall allows port 80

There are various solutions, that are all out of scope for this article.

But on OpenSUSE, you probably want to just do it via YaST.

Browse to the machine

Now you can browse to the machine that is running stable diffusion. In my case, this is d1.:

A screenshot of stable diffusion being accessed from another computer.
Above: A screenshot of stable diffusion being accessed from another computer.

Note that we no longer need to specify :7860 in the address bar.

Considerations

Path

In the configuration above, I’ve specified

    location / {

Automatic1111 breaks if you put it anywhere other than /. Solutions exist that will probably work for Automatic1111, but I have not yet tested any. I may do a follow-up post to this if there is interest.

Port

I’ve chosen port 80 here. You could put it on anything you like, including the original 7860 by modifying these lines:

    listen 80 default_server;
    listen [::]:80 default_server;

I expect that Automatic1111 would work fine with TLS(HTTPS) as well, but that is also out of scope for this article.

This post references

2022-03-07
The RandomKSandom series is the spiritual successor to FunnyHacks. Here, you can find all of the posts about it.
2024-09-26
I took some time to extend myself with some intellectual challenges. Here's what I've done so far.

Posts using the same tags

2024-09-26
I took some time to extend myself with some intellectual challenges. Here's what I've done so far.
It's time to blow the dust off machine learning, and apply it to a dataset that I know.
My CV had gained so much weight that it was hard to do anything with it any more, and it was hard to read. So I did something about it...
Control your computer using a Leap Motion controller, but with an every-day-quality implementation.
If you want to share stable diffusion on your network without exposing any information to the outside world. This is one way to do it.
There's a trick for getting a big speed boost on old hardware that's so easy that I'm surprised I haven't heard people talking about it.
What began as 3 tripods on a hill, and hours per photo, ended with way better results in seconds, hand held.
I accidentally automated Javelining a plane into the ground. And I learnt a huge amount along the way.
Over the last few years, there has been a lot of talk about whether you can make use of the full resolution on a phone with a 4K display. Let's dig in and actually understand this.
2022-11-17
Group of posts about the Astro Slide 5G.
I'm stopping my Patreon activity for now. Let's dive a little deeper into why.
4 easy phone hacks to make your phone more useful and fun
2022-03-07
The RandomKSandom series is the spiritual successor to FunnyHacks. Here, you can find all of the posts about it.
DoneIt is a time tracker for working out where your time is going. For me there were a few things I wanted to achieve with it - Be able to say what I've been doing all day. - See how much time is lost to time ...
Well over a year ago I introduced mass which is a tool for managing large numbers of servers. It's come along way in that time, and it's well and truly time for another look. From the users' point of view, the most interesting things are probably that you can now ...
Achel is a programming language that I have been working on for the past 13 years (I said 12 in the video, it has been a long time!) There has been growing interest in the programs I have been writing using it, so I have now released it as open ...

More...

Home | About | Contact | Cookies