404 Not Found Error Nginx Ubuntu 18.10

April 24, 2019 1.1k views
Nginx

Hello,
I’m using ubuntu 18.10 and configured Nginx on it. I tried to install Lets Encrypt , but when I tried to access my site, I got 404 error. I created a info.php and tried to open it with www.example.com/info.php and it doesnt work too.

Here is my default site-available config file:

server {
        listen "MyServerIP":443 ssl http2;
        listen [::]:443 ssl http2;

        server_name www."mydomain".de;
        set $base /var/www/woltlab/html;
        root $base/public;

        # SSL
        ssl_certificate /etc/letsencrypt/live/mydomain.de/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/mydomain.de/privkey.pem;
        ssl_trusted_certificate /etc/letsencrypt/live/mydomain.de/chain.pem;

        # logging
        access_log /var/log/nginx/mydomain.de.access.log;
        error_log /var/log/nginx/mydomain.de.error.log notice;

        # index.php
        index index.php;

        # index.php fallback
        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        # handle .php
        location ~ \.php$ {
                include nginxconfig.io/php_fastcgi.conf;
        }

        include nginxconfig.io/general.conf;
}

# non-www, subdomains redirect
server {
        listen "MyServerIP":443 ssl http2;
        listen [::]:443 ssl http2;

        server_name .mydomain.de;

        # SSL
        ssl_certificate /etc/letsencrypt/live/mydomain.de/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/mydomain.de/privkey.pem;
        ssl_trusted_certificate /etc/letsencrypt/live/mydomain.de/chain.pem;

        return 301 https://www.mydomain.de$request_uri;
}

# HTTP redirect
server {
        listen "MyServerIP":80;
        listen [::]:80;

        server_name .mydomain.de;

        include nginxconfig.io/letsencrypt.conf;

        location / {
                return 301 https://www.mydomain.de$request_uri;
        }
}

The Config file i created on nginxconfig.io.

The error.log is empty.

I´m new with Nginx and try to configure my own homepage.
I hope you can help me.

Thank you

1 comment
2 Answers

I configured it with server blocks. My website is stored under /var/www/woltlab/html/ and worked without SSL. With SSL this is no longer possible, even if I uninstall SSL.
For example, the other websites and services later run on forum.example.com and /var/www/forum/html.

The site exist under /var/www/woltlab/html and i created the info.php there too.

needed set same website root path at ssl host and http host in this file. Then put the page in the corresponding directory.

e.g: i have one website in /var/www/web1, so i need set sites-availble config file “root” line is /var/www/web1 (include redirct host)

after that can create index.html test is working status.

nginx default home page types is index.html index.php index.htm
if need change, can add a this line.

index index.html index.php index.htm; #input you want to settings index page file name
Have another answer? Share your knowledge.