Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

200
Visualizações
How configure nginx to give access to storage folder?

I have the following nginx configuration that works fine. I have an API (Expressjs) on /api location and a Frontend Development (Vuejs) in /:

server {
        server_name example.com www.example.com;

        root /var/www/domain.com/public_html;

        index index.html index.htm;

        location / {
                try_files $uri $uri/ /index.html =404;
        }

        location /api {

                proxy_set_header 'Access-Control-Allow-Origin' 'https://example.com';
                proxy_set_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
                proxy_set_header 'Access-Control-Allow-Headers' 'X-Requested-With,Accept,Content-type,Origin';

                proxy_pass http://127.0.0.1:8000;
                proxy_redirect off;
                proxy_buffering on;

                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        origin          'https://example.com';
        }

In my API I have a public folder (public/storage/) where I can store images. But when trying to access that folder I'm having 404 error. How can I configure my nginx server to giving access to the storage folder?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Please note when the request URI is: http://example.com/api/public/storage/image.jpg

Then the request for the proxy will be the same as well. e.g

http://127.0.0.1:8000/api/public/storage/image.jpg

If you would like to change that, you should add URI to the directive proxy_pass itself. e.g

proxy_pass http://127.0.0.1:8000/public/;.

which will map requests to :

http://127.0.0.1:8000/public/public/storage/image.jpg

(there is double public intentionally.)

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda