Strapi /admin gives 404 errors after redirect Nginx

After installing Strapi I only get error messages.

What have I done so far?


# Strapi API and Admin
        location /api/ {
                rewrite ^/api/?(.*)$ /$1 break;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-Host $host;
                proxy_set_header X-Forwarded-Server $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_set_header Host $http_host;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                proxy_pass_request_headers on;


module.exports = ({ env }) => ({
host: env(‘HOST’, ‘’),
port:‘PORT’, 1337),
url: env(“PUBLIC_URL”, “Welcome to your Strapi app”),
app: {
keys: env.array(‘APP_KEYS’),

I am getting the following error messages:

The images and js not loading?

clicking the button to create an admin user a new page to /admin opens and gives the error in the console

Failed to load resource: the server responded with a status of 404 () runtime~main.f6ccac5d.js:1
Failed to load resource: the server responded with a status of 404 () main.75a19cc0.js:1

Is there anyone who knows what the problem could be?

I too am facing this issue (or at the least a very similar issue) - it’s driving me up the wall.

I’ve outlined more detail on a stackoverflow question here: Strapi admin API on subfolder hitting 404 on JS files behind nginx reverse proxy - Stack Overflow

Any help would be greatly appreciated.

I am facing the same issue.
If served directly by Haproxy, it works.
If served Haproxy > Nginx, it doesn’t work.

Did everything by Strapi docs.
It can’t find anything under /admin. Nginx screams File Not Found in /etc/nginx/html/… .js
This way it can’t find robots.txt either

I tried to set the root path in Nginx to /path/to/public.
This way it found robots.txt, and responds to /, but nothing else.

Same issue.

url: env(“PUBLIC_URL” , "”),

on your .env do you have a PUBLIC_URL env that is attached to it?
also when you update the config on server.js did you then build the strapi again

i recently ran into a similar issues

  1. admin image not showing as the URL is not set up properly → changing the url value via .env or the url in the server.js
  2. admin page itself loaded but blank and have 404 errors for the main.js as the URL pointed to the wrong path → Build the strapi again after changing configurations (maybe also have a look on the network tab to see if the 404)

hopefully, it could help you out, but im by no means any expert

Perhaps you need also to rewrite /admin, /assets, /upload, …

It might be better to have a virtual server and use location /, assuming you have multiple services on the same Nginx instance

Would be easier than trying to figure out and maintain all the routes needed.

@Vitali: Strapi Admin is working for me

i fixed it :smiley:

@Vitali To help others, it is nice to tell how you solved it and not to delete you’re post.