0

I have set up Nginx on my server to serve static files for a front-end application. The root URL (http://xxx.85.127.14/) correctly serves files, but when I try to access http://xxx.85.127.14/admin I get an ERR_EMPTY_RESPONSE error in the browser.

However, when I test locally it works:
curl -I http://localhost/admin

Server & Environment Details:

  • OS: Ubuntu 20.04

  • Web Server: Nginx

  • Frontend Framework: React/Vue (if applicable)

  • Deployment Directory:

    • /root/deployment/user/dist (for /) user

    • /root/deployment/admin/dist (for /admin)

Nginx Configuration (/etc/nginx/sites-available/default)

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name xxx.85.127.14;
    location / {
        root /root/deployment/user/dist;
        index index.html;
        try_files $uri /index.html;
    }

    location /admin {
        root /root/deployment/admin/dist;
        index index.html;
        try_files $uri /index.html;
    }


    location /api/ {
        proxy_pass http://localhost:5000/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
4
  • Did you get nginx tell you why in the logs (why not by dumping them to a custom file, and even setting the log level to a higher level like info)? This may be as simple as a rights problem… Commented Feb 20 at 8:03
  • hey @GuillaumeOutters I did not get it can you please tell me in more detail how to fix the issue I'm new to deployment Commented Feb 20 at 9:31
  • Add an error_log /tmp/nginx_error.log info; access_log /tmp/nginx_access.log info; at the start of your nginx config file, restart your nginx, try to access first your / then your /admin and then look into the aforementionned .log files for something indicating it cannot access admin; or if nothing looks strange, compare the parts corresponding to an access to / and an access to /admin, to see at which step /admin returned prematurely while / continued until it served the page. Commented Feb 20 at 10:25
  • This is not to solve your problem, but to investigate the cause (and later get more autonomy, and speed, in solving those kind of problems). Commented Feb 20 at 10:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.