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

Trouble with File Upload in Self-Hosted Supabase Using Docker #16857

Open
2 tasks done
xyberninja opened this issue Aug 26, 2023 · 37 comments
Open
2 tasks done

Trouble with File Upload in Self-Hosted Supabase Using Docker #16857

xyberninja opened this issue Aug 26, 2023 · 37 comments
Assignees
Labels
bug Something isn't working self-hosted Issues related to self hosting storage

Comments

@xyberninja
Copy link

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I'm currently facing a perplexing problem while attempting to manually upload files to the Supabase bucket on my self-hosted instance using Docker. The issue arises when I initiate the upload process – the progress gets stuck at 0% and the upload never seems to commence. I've conducted this experiment on multiple computers and have tried various file types, yet regrettably, none of these attempts have proved successful.

To Reproduce

  1. Set up self-hosted Supabase instance using Docker.
  2. Open the dashboard and head to bucket
  3. Upload one/multiple files

Expected behavior

The manual file upload process should initiate normally, progressing from 0% to completion, allowing the files to be uploaded successfully to the Supabase bucket.

Screenshots

anydesk00000

System information

  • OS: Rocky Linux 9
  • Browser: Microsoft Edge, Chrome
  • Version of supabase-js: latest
  • Version of Node.js: 20.5.1

Additional context

  • I have ensured that I haven't made any erroneous configurations in my settings, but I'm open to the possibility that I might have missed something crucial.
  • Interestingly, upon executing the command "docker ps -a," I can confirm that the storage function is indeed running, which adds a layer of complexity to diagnosing the issue.
CONTAINER ID   IMAGE                              COMMAND                   CREATED       STATUS                 PORTS                                                                                                      NAMES
99cba4c80bfd   supabase/studio:20230803-15c6762   "docker-entrypoint.s…"    5 hours ago   Up 5 hours (healthy)   3000/tcp                                                                                                   supabase-studio
0bf0b15ad154   kong:2.8.1                         "bash -c 'eval \"echo…"   5 hours ago   Up 5 hours (healthy)   8001/tcp, 8444/tcp, 0.0.0.0:8443->8443/tcp, :::8443->8443/tcp, 0.0.0.0:9090->8000/tcp, :::9090->8000/tcp   supabase-kong
3f503c1ccc79   supabase/gotrue:v2.82.4            "gotrue"                  5 hours ago   Up 5 hours (healthy)                                                                                                              supabase-auth
e13f590b99db   supabase/storage-api:v0.40.4       "docker-entrypoint.s…"    6 hours ago   Up 5 hours (healthy)   5000/tcp                                                                                                   supabase-storage
6fa902be473d   supabase/realtime:v2.10.1          "/usr/bin/tini -s -g…"    6 hours ago   Up 5 hours (healthy)                                                                                                              realtime-dev.supabase-realtime
292f88628506   supabase/postgres-meta:v0.68.0     "docker-entrypoint.s…"    6 hours ago   Up 5 hours (healthy)   8080/tcp                                                                                                   supabase-meta
62c838b1be5b   supabase/edge-runtime:v1.8.1       "edge-runtime start …"    6 hours ago   Up 5 hours                                                                                                                        supabase-edge-functions
53348c9dea10   postgrest/postgrest:v11.1.0        "/bin/postgrest"          6 hours ago   Up 5 hours             3000/tcp                                                                                                   supabase-rest
451d2fc42946   supabase/logflare:1.4.0            "sh -c '`cat <<EOF >…"    6 hours ago   Up 5 hours (healthy)                                                                                                              supabase-analytics
2a55f9cfb9ab   supabase/postgres:15.1.0.103       "docker-entrypoint.s…"    6 hours ago   Up 5 hours (healthy)   127.0.0.1:5432->5432/tcp                                                                                   supabase-db
8d4e8023a5a8   darthsim/imgproxy:v3.8.0           "imgproxy"                6 hours ago   Up 5 hours (healthy)   8080/tcp                                                                                                   supabase-imgproxy
2e3845edc3d9   timberio/vector:0.28.1-alpine      "/usr/local/bin/vect…"    6 hours ago   Up 5 hours (healthy)   0.0.0.0:9500-9001->9500-9001/tcp, :::9500-9001->9500-9001/tcp                                              supabase-vector
  • It's worth mentioning that I've also port forwarded the dashboard port to my domain as part of the setup.
@xyberninja xyberninja added the bug Something isn't working label Aug 26, 2023
@GaryAustin1 GaryAustin1 added self-hosted Issues related to self hosting storage labels Aug 26, 2023
@xyberninja
Copy link
Author

Bumping

@aabulmagd
Copy link

I have the same behaviour, running supabase on docker inside a nested unprevilages LXC container on proxmox.

@ivasilov
Copy link
Member

Should be fixed by #17587.

Edit the docker-compose.yml and update to the latest docker image which should be out next Tuesday, you can check here.

Please reopen and ping me if the issue still persists.

@aabulmagd
Copy link

@ivasilov Problem Still exists with studio:v0.23.09_amd64 with this error:
Failed to load resource: the server responded with a status of 404 (Not Found)
:8000/api/integrations/default-org-slug?expand=true:1 Failed to load resource: the server responded with a status of 404 (Not Found)
:8000/api/integrations/default-org-slug?expand=true:1 Failed to load resource: the server responded with a status of 404 (Not Found)
localhost:8000/storage/v1/object/assets/IMG_6990 Large.jpeg:1 Failed to load resource: net::ERR_CONNECTION_REFUSED

@ivasilov ivasilov reopened this Oct 10, 2023
@dfang
Copy link

dfang commented Oct 22, 2023

Should be fixed by #17587.

Edit the docker-compose.yml and update to the latest docker image which should be out next Tuesday, you can check here.

Please reopen and ping me if the issue still persists.

@ivasilov, the latest image tag is v0.23.09

same issue as @aabulmagd.

any progress ?

@nicetomytyuk
Copy link
Contributor

nicetomytyuk commented Oct 24, 2023

@dfang having the same issue:

image

I've just updated the docker-compose with studio version v0.23.09 but still having those console log errors.

@pers0na2dev
Copy link

Same thing

@ahachicha
Copy link

same thing, the progress gets stuck at 0%.

any progress pls?

@pers0na2dev
Copy link

As it turns out I had a problem with the http (not https) specified in the .env, since I'm using nginx over kong with custom SSL certificates.

@ahachicha
Copy link

I managed to upload files with a python script.

@kdamsmt
Copy link

kdamsmt commented Nov 23, 2023

Should be fixed by #17587.

Edit the docker-compose.yml and update to the latest docker image which should be out next Tuesday, you can check here.

Please reopen and ping me if the issue still persists.

Not help at all even update to latest docker image.
image

image

Video

@saltcod
Copy link
Contributor

saltcod commented Nov 27, 2023

Hi all — this still an issue? Just tested and looks resolved to me.

@Dragonslayer42069
Copy link

Dragonslayer42069 commented Nov 28, 2023

Got the same problem here on my side.

Running via Docker too and changed every localhost to my local ip (192.168.1.202) in the .env file. When uploading via bucket gui on my browser the POST method get postet to http://localhost:8000/storage/v1/object/files/

All GET methods are resolved under http://192.168.1.202:8000/api/storage/default/buckets

//edit

So today I got back to my office and tried to upload a file again. Now it routes correctly to my lan ip.
My .env values

SITE_URL=http://192.168.1.202:3000
ADDITIONAL_REDIRECT_URLS=
JWT_EXPIRY=3600
DISABLE_SIGNUP=false
API_EXTERNAL_URL=http://192.168.1.202:8000
SUPABASE_PUBLIC_URL=http://192.168.1.202:8000

Its strange it works today because i haven´t change anything overnight. Maybe its useful.

@kdamsmt
Copy link

kdamsmt commented Dec 11, 2023

Got the same problem here on my side.

Running via Docker too and changed every localhost to my local ip (192.168.1.202) in the .env file. When uploading via bucket gui on my browser the POST method get postet to http://localhost:8000/storage/v1/object/files/

All GET methods are resolved under http://192.168.1.202:8000/api/storage/default/buckets

//edit

So today I got back to my office and tried to upload a file again. Now it routes correctly to my lan ip. My .env values

SITE_URL=http://192.168.1.202:3000 ADDITIONAL_REDIRECT_URLS= JWT_EXPIRY=3600 DISABLE_SIGNUP=false API_EXTERNAL_URL=http://192.168.1.202:8000 SUPABASE_PUBLIC_URL=http://192.168.1.202:8000

Its strange it works today because i haven´t change anything overnight. Maybe its useful.

It's worked for me. @supabase should auto modify script installation to detect localhost to IP.

@artT14
Copy link

artT14 commented Dec 14, 2023

Getting the same issue here, I am able to upload via SDK but not via studio GUI

@Alirezaaraby
Copy link

I have the same error.

@tranhoangvuit
Copy link
Contributor

Hi guys, this still an issue? I've just pulled the latest version, and it works fine for me. If possible, could you guys post some images of the logs for storage or studio?

@lars-sorensen
Copy link

lars-sorensen commented Jan 1, 2024

I have the same error when trying to upload. Can't pull the logs as when I run the default query I get:
{ "code": 502, "errors": [], "message": "Something went wrong! Unknown error. If this continues please contact support.", "status": "UNKNOWN" }

Skærmbillede 2024-01-01 kl  12 30 00

The DB seems to work fine. Via studio I add tables and data

The setup is brand new pull on hetzner cloud. No env changes as I understood from the docs that I should work fine as is (just testing here, so no security risks)

@ivasilov
Copy link
Member

ivasilov commented Jan 3, 2024

I've looked into this more closely, this comment solves it. You need to set SUPABASE_PUBLIC_URL to your URL in the .env file. It doesn't matter from which URL you're accessing the studio (you can even access it directly via its IP address), uploading of files (and some other minor features) are using that env variable since they're using the supabase-js library. You can see this behavior if you look closely in the URLs for the /upload POST and other GET requests.

If you're still seeing this issue, please share your SITE_URL, API_EXTERNAL_URL, SUPABASE_PUBLIC_URL and KONG_HTTP_PORT.

@lars-sorensen
Copy link

Still have the issue.

My env:
SITE_URL=http://49.***.***.68:3000/
API_EXTERNAL_URL=http://49.***.***.68:8000/
SUPABASE_PUBLIC_URL=http://49.***.***.68:8000/
KONG_HTTP_PORT=8000

@lars-sorensen
Copy link

it is a clean install on Hetzner I don't use for anything right now, so if you want to, you are welcome to investigate on the system itself.

@ivasilov
Copy link
Member

ivasilov commented Jan 9, 2024

it is a clean install on Hetzner I don't use for anything right now, so if you want to, you are welcome to investigate on the system itself.

Yeah, that would be great! Can you email me more info at [email protected] about your instance?

@lichong-a
Copy link

It reproduces when I use docker self-hosted deployment. There are 4 interfaces with 404 and the dashboard/projects cannot be accessed.
image
image

@CptMorningWood
Copy link

Had the exact same issue..
Changing all "localhost" to my IP in the .env file fixed it for me.

@besteman
Copy link

besteman commented Mar 4, 2024

any update on this? Have the same issue

@wazzaarr
Copy link

wazzaarr commented Mar 5, 2024

Same issue, changed all localhost to the appropriate LAN IP in the .env file. Docker restart. Still no uploads via studio.
I am using Nginx Proxy Manager. That's the only difference I can think of.

@wazzaarr
Copy link

wazzaarr commented Mar 5, 2024

Ok, I got this working.
I'm accessing Studio externally. I'm using Nginx Proxy Manager.
I have a base url at 8000 and made a new url to point to 3000
In the .env file I changed:
SITE_URL=https://my-extradomain.com (no port - NPM does this for you)
and
API_EXTERNAL_URL=https://my-basedomain.com (again no port)
I also changed
SUPABASE_PUBLIC_URL=https://my-basedomain.com (no port)

Notice the https as it's a public route through your proxy.
I'm not a security expert so please feel free to let me know if this is not ok. It's working though. There are still lots of error in the javascript console but I think that's a different issue.

@nicetomytyuk
Copy link
Contributor

I'm having still those errors in console.log() but at functional level all seems to work correctly:

image

@ivasilov
Copy link
Member

ivasilov commented Mar 6, 2024

Ok, I got this working. I'm accessing Studio externally. I'm using Nginx Proxy Manager. I have a base url at 8000 and made a new url to point to 3000 In the .env file I changed: SITE_URL=https://my-extradomain.com (no port - NPM does this for you) and API_EXTERNAL_URL=https://my-basedomain.com (again no port) I also changed SUPABASE_PUBLIC_URL=https://my-basedomain.com (no port)

Notice the https as it's a public route through your proxy. I'm not a security expert so please feel free to let me know if this is not ok. It's working though. There are still lots of error in the javascript console but I think that's a different issue.

Just a quick intro to all these env vars:

  • SITE_URL is the url to your Studio instance. Studio is optional and lives separate than the rest of the containers. This is the supabase.com/dashboard on our managed environment.
  • API_EXTERNAL_URL and SUPABASE_PUBLIC_URL are the same thing and should point to where your db, auth, realtime and storage containers are. This is the same as <project-ref>.supabase.co on our managed environment. Studio also uses these env vars for some of the features.

I'm having still those errors in console.log() but at functional level all seems to work correctly:

image

Those are ok. Not important when self-hosting.

@nicetomytyuk
Copy link
Contributor

@ivasilov it would be cool to be able to remove the subscriptions module for self-hosted so to prevent all those errors.

@theghostbel
Copy link

  • SITE_URL is the url to your Studio instance. Studio is optional and lives separate than the rest of the containers. This is the supabase.com/dashboard on our managed environment.
    This is my .env part with URLs:
## General
SITE_URL=http://localhost:3000
ADDITIONAL_REDIRECT_URLS=
JWT_EXPIRY=3600
DISABLE_SIGNUP=false
API_EXTERNAL_URL=http://localhost:8000

Can't open http://localhost:3000 in browser, http://localhost:8000 works well though. And also having a lot of 404 and not working AI SQL helper - trying to use gives a huge unclosable error popup (HTTP/1.1 500 Internal Server Error).

curl query and screenshot here
curl 'http://localhost:8000/api/ai/sql/edit' \
  -H 'Accept: application/json' \
  -H 'Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,et;q=0.6' \
  -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Cookie: _logflare_key=SFMyNTY.g3QAAAACbQAAAAtfY3NyZl90b2tlbm0AAAAYcWlXX2lhaFpudy1tOVMtR19GYnhpWmVEbQAAAAd1c2VyX2lkYQE.j8AUTkki4J8Fn9TAj7SLQkvMSUbyYEszcmwikTKltnY; __stripe_mid=120755d5-e809-4eb0-9064-c63216755c666c7008' \
  -H 'Origin: http://localhost:8000' \
  -H 'Referer: http://localhost:8000/project/default/sql/1' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36' \
  -H 'X-Request-Id: 7492f881-a6f6-4ecc-b373-f91b3668c586' \
  -H 'sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"' \
  --data-raw $'{"prompt":"show current postgre version","sql":"select * from\\n  (select version()) as version,\\n  (select current_setting(\'server_version_num\')) as version_number;","entityDefinitions":["CREATE  TABLE public.mydata (\\n  id bigint GENERATED BY DEFAULT AS IDENTITY ,\\n  text text NOT NULL,\\n  CONSTRAINT mydata_pkey PRIMARY KEY (id)\\n) TABLESPACE pg_default;"]}'

image

@hugotox
Copy link

hugotox commented Mar 9, 2024

Same issue on a fresh local supabase instance. I've tried to create a folder in my storage bucket and getting this error

_app-5e117e56c49dd8be.js:5 Refused to connect to 'http://127.0.0.1:54321/storage/v1/object/stickmonkey-media/aircrafts/.emptyFolderPlaceholder' because it violates the following Content Security Policy directive: "default-src 'self'  http://localhost:8000 http://localhost:8000 https://*.supabase.co wss://*.supabase.co https://*.hcaptcha.com https://cdn-global.configcat.com https://*.stripe.com https://*.stripe.network https://www.cloudflare.com https://1.1.1.1 https://*.vercel-insights.com https://api.github.com https://raw.githubusercontent.com". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
_app-5e117e56c49dd8be.js:5 Refused to connect to 'http://127.0.0.1:54321/storage/v1/object/stickmonkey-media/aircrafts/.emptyFolderPlaceholder' because it violates the document's Content Security Policy.
image

@Rocke1001feller
Copy link

Ok, I got this working. I'm accessing Studio externally. I'm using Nginx Proxy Manager. I have a base url at 8000 and made a new url to point to 3000 In the .env file I changed: SITE_URL=https://my-extradomain.com (no port - NPM does this for you) and API_EXTERNAL_URL=https://my-basedomain.com (again no port) I also changed SUPABASE_PUBLIC_URL=https://my-basedomain.com (no port)

Notice the https as it's a public route through your proxy. I'm not a security expert so please feel free to let me know if this is not ok. It's working though. There are still lots of error in the javascript console but I think that's a different issue.

I am triy to answer this question. I'm also using Nginx Proxy Manager. When we need to access the storage service, Nginx Proxy Manager will proxy the request to our self-hosted server. And the configuration on the server shows that this request needs to be processed by localhost:8000. So, the javascript console shows that our request is forwarded to localhost:8000. And this localhost will be interpreted as the machine where our own client is located, not the localhost on the remote host. Therefore, the upload fails.

So, you change the service address in .env to your domain name (https://my-extradomain.com/). I think it works and is also secure. Because Nginx Proxy Manager will redirect to this address when making a request for the storage service. And this request is still SSL encrypted. It will not expose internal information of the server. How do others understand this process? Proxy Manager will redirect to this address when making the request to the storage service. And this request is still SSL encrypted. It will not expose the internal information of the server.

How do others understand this process?

@ivasilov
Copy link
Member

Nginx Proxy Manager

AFAIK the connection between user and nginx will be secured (across the whole internet).

The connection between nginx and self-hosted supabase will be non-encrypted because nginx does SSL termination. In reality, this shouldn't matter because nginx and the supabase are usually on the same server OR in the same trusted virtual network.

@ReyNow
Copy link

ReyNow commented Apr 22, 2024

I face the same issue: spinning loading bar at 0%.

The Console in Firefox first shows an issue with Cross-Origin and CORS and afterwards:
grafik

In Edge I get
POST http://localhost:8000/storage/v1/object/xyz/abc.jpg net::ERR_CONNECTION_REFUSED
and
grafik

I changed the ~/supabase/docker/.env from localhost to the real ip, as mentioned as a fix above. But it won't work and as you see, the POST request still uses localhost.

@danielrosehill
Copy link

Can neither upload to buckets nor create users with authentication from the web UI

@Alvigo
Copy link

Alvigo commented Jun 24, 2024

Fresh installed supabase sehfhost on VPS NGNIX (by https://blog.activeno.de/the-ultimate-supabase-self-hosting-guide). Same bug in studio - cannot add user nor create folder in the backet nor upload file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working self-hosted Issues related to self hosting storage
Projects
Development

No branches or pull requests