0

I have been trying to configure my nginx vuejs static frontend. My site consistently returns a 500. I based my /etc/nginx/nginx.conf file this site.

When I go to the specified ip_address, the 500 screen is returned and returns specifically 500 Internal Server Error nginx/1.12.2.

Why would it do this? I know that the root filepath is correct but it apparently can't seem to find it.

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  floating_ip_address;
    root         ~/frontendFolder;
    index        index.html

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
         try_files $uri $uri/ @rewrites;
    }

    location @rewrites {
         rewrite ^(.+)$ /index.html last;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

EDIT:

The most recent logs are as follows:

ip - - [12/Sep/2018:16:39:59 +0000] "GET /phpmyadmin-old/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:00 +0000] "GET /phpMyAdminold/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:00 +0000] "GET /phpMyAdmin.old/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:03 +0000] "GET /pma-old/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:03 +0000] "GET /claroline/phpMyAdmin/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:05 +0000] "GET /typo3/phpmyadmin/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:07 +0000] "GET /phpma/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:07 +0000] "GET /phpmyadmin/phpmyadmin/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:40:15 +0000] "GET /phpMyAdmin/phpMyAdmin/index.php HTTP/1.1" 200 3700 "-" "Mozilla/5.0" "-"
ip - - [12/Sep/2018:16:44:37 +0000] "GET / HTTP/1.1" 200 3700 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7" "-"
ip - - [12/Sep/2018:16:47:28 +0000] "GET / HTTP/1.1" 500 595 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36" "-"
2
  • What's in the log? Commented Sep 12, 2018 at 3:47
  • Which log? If I run service nginx status, then there are no errors, it has started and is active (running). Commented Sep 12, 2018 at 16:57

3 Answers 3

3

i had the same issue with my Vue project, I'm 100% sure that my nginx server block is good. Here is an example:

server {
listen      80;
server_name example.com www.example.com;        charset utf-8;
root    /var/www/myapp/dist;
index   index.html;
#Always serve index.html for any request
location / {
    root /var/www/myapp/dist;
    try_files $uri  /index.html;
}
error_log  /var/log/nginx/vue-app-error.log;
access_log /var/log/nginx/vue-app-access.log;
}

but, I get the error 500. also i assign the execution permission to dist/ folder and nginx user ownership of file:

chown -R www-data:www-data ./dist/*

and

chmod 755 -R ./dist/*

nginx 500 error on vue

SOLUTION

-1 check the www-data user has the path/ file permission

root@root:# sudo -u www-data stat /home/myuser/public_html/

OUTPUT:

sudo: /etc/sudo.conf is group writable sudo: /etc/sudo.conf is group writable File: /home/efficonx/public_html/ Size: 4096
Blocks: 8 IO Block: 4096 directory Device: fc01h/64513d
Inode: 258318 Links: 4 Access: (0775/drwxrwxr-x) Uid: ( 0/
root) Gid: ( 0/ root) Access: 2022-12-07 13:48:55.245310115 +0000 Modify: 2022-12-06 13:13:40.187999036 +0000 Change: 2022-12-07 13:48:33.149826680 +0000 Birth: 2022-12-06 07:34:49.277257817 +0000

-2 if the www-data have no permission then assign him group/permission in my case i add him to root user group

sudo adduser www-data root

and all DONE.

Sign up to request clarification or add additional context in comments.

Comments

2

Update the first line in /etc/nginx/nginx.conf

user www-data;

to

user ubuntu;

1 Comment

Just had the same issue, this solved it for me after days of trying. Thank you!
0

I'm not an nginx guru but we have a production server running nginx to serve a static Vue website and proxy API and WebSocket requests to a Butterfly Server .NET running on port 8200.

Anyways, this is our nginx config file, hope it helps...

server {
    listen                      80;
    listen          [::]:80;
    server_name                 my.mysite.com;
    root                        /opt/mysite/my;
    return 301 https://my.mysite.com$request_uri;
}

server {
    listen          443 default_server ssl;
    server_name                 my.mysite.com;
    ssl_certificate     /opt/mysite/ssl/my_mysite_io.bundle.crt;
    ssl_certificate_key     /opt/mysite/ssl/my_mysite_io.key;
    root                        /opt/mysite/my;
    client_max_body_size        128000000;

    # index
    index index.html;

    # $uri, index.html
    location / {
        try_files $uri $uri/ /index.html;
    }

    location ~* \.(?:jpg|jpeg|png|ico)$ {
        expires 1y;
        add_header Cache-Control "public";
        access_log off;
    }

    location /index.html {
        expires -1;
        add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate";
    }

    location /api {
        proxy_pass http://127.0.0.1:8200;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }

    location /ws {
        proxy_pass http://127.0.0.1:8200;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }

}

2 Comments

Is anything in your config optional? Is the /api optional? My api is independent from my ui, so I omitted it? Trying to understand nginx better. I assumed it would work once I gave it the correct path but that was clearly naive.
Yes, both the /api and /ws location sections are only needed to proxy those type of requests to another server. Remove those if you like. I'm not an nginx guru either -- I was just sharing what we had working on our server.

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.