Question

404 Not Found Error Nginx Ubuntu 18.10

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

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

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.