Results 1 to 10 of 10

Thread: 404 Not Found error with nginx

  1. #1
    Join Date
    Dec 2010
    Beans
    405

    404 Not Found error with nginx

    I have a subdomain called mail on mydomain.com. I am running nginx on the server. I have a mail.mydomain.com.conf file in sites-available, and linked in the sites-enabled folder. My server's hostname is "mail". In the .conf file, I've set the server_name to mail.mydomain.com, and root to /var/www/html/roundcube. I want to be able to access the installer/index.php file. I go to in my browser, mail.mydomain.com/installer, and I get a 404 Not Found error message. The files/folders are owned by www-data. What am I doing wrong?

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: 404 Not Found error with nginx

    Quote Originally Posted by sniper8752 View Post
    I go to in my browser, mail.mydomain.com/installer, and I get a 404 Not Found error message. The files/folders are owned by www-data. What am I doing wrong?
    You didn't actually post the config file for the site or the ls -al for the location with the files you expect to work.
    You didn't say if you setup DNS either.
    Did you look at the nginx log files for that specific domain? What's in the access log and the error log?

  3. #3
    Join Date
    Dec 2010
    Beans
    405

    Re: 404 Not Found error with nginx

    I installed the following for DNS: bind9 bind9utils bind9-dnsutils bind9-doc bind9-host.
    The roundcube directory:

    Code:
    ls -al
    total 508
    drwxrwxr-x 17 www-data www-data   4096 Nov  6 16:09 .
    drwxr-xr-x  3 root     root       4096 Nov  6 16:19 ..
    -rw-rw-r--  1 www-data www-data    252 Nov  6 15:54 .editorconfig
    drwxrwxr-x  8 www-data www-data   4096 Nov  6 15:54 .git
    drwxrwxr-x  3 www-data www-data   4096 Nov  6 15:54 .github
    -rw-rw-r--  1 www-data www-data    527 Nov  6 15:54 .gitignore
    -rw-rw-r--  1 www-data www-data   2551 Nov  6 15:54 .htaccess
    drwxrwxr-x  2 www-data www-data   4096 Nov  6 15:54 .tx
    -rw-rw-r--  1 www-data www-data 200198 Nov  6 15:54 CHANGELOG.md
    -rw-rw-r--  1 www-data www-data  12661 Nov  6 15:54 INSTALL
    -rw-rw-r--  1 www-data www-data  35147 Nov  6 15:54 LICENSE
    -rw-rw-r--  1 www-data www-data   4130 Nov  6 15:54 Makefile
    -rw-rw-r--  1 www-data www-data   4133 Nov  6 15:54 README.md
    -rw-rw-r--  1 www-data www-data    967 Nov  6 15:54 SECURITY.md
    drwxrwxr-x  7 www-data www-data   4096 Nov  6 15:54 SQL
    -rw-rw-r--  1 www-data www-data   4657 Nov  6 15:54 UPGRADING
    drwxrwxr-x  2 www-data www-data   4096 Nov  6 15:54 bin
    -rw-rw-r--  1 www-data www-data    979 Nov  6 15:54 composer.json
    -rw-rw-r--  1 www-data www-data 127619 Nov  6 16:04 composer.lock
    drwxrwxr-x  2 www-data www-data   4096 Nov  6 15:54 config
    -rw-rw-r--  1 www-data www-data  11191 Nov  6 15:54 index.php
    drwxrwxr-x  3 www-data www-data   4096 Nov  6 15:54 installer
    -rw-rw-r--  1 www-data www-data   4298 Nov  6 15:54 jsdeps.json
    drwxrwxr-x  2 www-data www-data   4096 Nov  6 23:13 logs
    drwxrwxr-x 37 www-data www-data   4096 Nov  6 15:54 plugins
    drwxrwxr-x  8 www-data www-data   4096 Nov  6 15:54 program
    drwxrwxr-x  3 www-data www-data   4096 Nov  6 15:54 public_html
    drwxrwxr-x  5 www-data www-data   4096 Nov  6 15:54 skins
    drwxrwxr-x  2 www-data www-data   4096 Nov  6 15:54 temp
    drwxrwxr-x  7 www-data www-data   4096 Nov  6 15:54 tests
    drwxrwxr-x 13 www-data www-data   4096 Nov  6 16:04 vendor
    
    

    The installer directory:
    Code:
    ls -al
    total 84
    drwxrwxr-x  3 www-data www-data  4096 Nov  6 15:54 .
    drwxrwxr-x 17 www-data www-data  4096 Nov  6 16:09 ..
    -rw-rw-r--  1 www-data www-data  9222 Nov  6 15:54 check.php
    -rw-rw-r--  1 www-data www-data  1655 Nov  6 15:54 client.js
    -rw-rw-r--  1 www-data www-data 22714 Nov  6 15:54 config.php
    drwxrwxr-x  2 www-data www-data  4096 Nov  6 15:54 images
    -rw-rw-r--  1 www-data www-data  6734 Nov  6 15:54 index.php
    -rw-rw-r--  1 www-data www-data  3348 Nov  6 15:54 styles.css
    -rw-rw-r--  1 www-data www-data 16448 Nov  6 15:54 test.php
    
    

    the mail.mydomain.com.conf file:

    Code:
    server {
        listen 80;
        server_name mail.mydomain.com;
        root /var/www/html/roundcube;
    
    
        error_log /var/log/nginx/roundcube.error;
        access_log /var/log/nginx/roundcube.access;
    
    
        location ~ /.well-known/acme-challenge {
          allow all;
        }
       location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
          deny all;
        }
        location ~ ^/(bin|SQL)/ {
          deny all;
        }
       # A long browser cache lifetime can speed up repeat visits to your page
        location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
           access_log        off;
           log_not_found     off;
           expires           360d;
        }
    
    
        index index.php index.html index.htm;
    
    
        location / {
            try_files $uri $uri/ =404;
        }
    
    
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
         }
    
    
        location ~ /\.ht {
            deny all;
        }
    
    
    }




  4. #4
    Join Date
    Oct 2017
    Location
    City of Waterfalls-Ph
    Beans
    Hidden!
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: 404 Not Found error with nginx

    Quote Originally Posted by sniper8752 View Post
    I installed the following for DNS: bind9 bind9utils bind9-dnsutils bind9-doc bind9-host.
    The roundcube directory:

    Code:
    ls -al
    total 508
    drwxrwxr-x 17 www-data www-data   4096 Nov  6 16:09 .
    drwxr-xr-x  3 root     root       4096 Nov  6 16:19 ..
    -rw-rw-r--  1 www-data www-data    252 Nov  6 15:54 .editorconfig
    drwxrwxr-x  8 www-data www-data   4096 Nov  6 15:54 .git
    drwxrwxr-x  3 www-data www-data   4096 Nov  6 15:54 .github
    -rw-rw-r--  1 www-data www-data    527 Nov  6 15:54 .gitignore
    -rw-rw-r--  1 www-data www-data   2551 Nov  6 15:54 .htaccess
    drwxrwxr-x  2 www-data www-data   4096 Nov  6 15:54 .tx
    -rw-rw-r--  1 www-data www-data 200198 Nov  6 15:54 CHANGELOG.md
    -rw-rw-r--  1 www-data www-data  12661 Nov  6 15:54 INSTALL
    -rw-rw-r--  1 www-data www-data  35147 Nov  6 15:54 LICENSE
    -rw-rw-r--  1 www-data www-data   4130 Nov  6 15:54 Makefile
    -rw-rw-r--  1 www-data www-data   4133 Nov  6 15:54 README.md
    -rw-rw-r--  1 www-data www-data    967 Nov  6 15:54 SECURITY.md
    drwxrwxr-x  7 www-data www-data   4096 Nov  6 15:54 SQL
    -rw-rw-r--  1 www-data www-data   4657 Nov  6 15:54 UPGRADING
    drwxrwxr-x  2 www-data www-data   4096 Nov  6 15:54 bin
    -rw-rw-r--  1 www-data www-data    979 Nov  6 15:54 composer.json
    -rw-rw-r--  1 www-data www-data 127619 Nov  6 16:04 composer.lock
    drwxrwxr-x  2 www-data www-data   4096 Nov  6 15:54 config
    -rw-rw-r--  1 www-data www-data  11191 Nov  6 15:54 index.php
    drwxrwxr-x  3 www-data www-data   4096 Nov  6 15:54 installer
    -rw-rw-r--  1 www-data www-data   4298 Nov  6 15:54 jsdeps.json
    drwxrwxr-x  2 www-data www-data   4096 Nov  6 23:13 logs
    drwxrwxr-x 37 www-data www-data   4096 Nov  6 15:54 plugins
    drwxrwxr-x  8 www-data www-data   4096 Nov  6 15:54 program
    drwxrwxr-x  3 www-data www-data   4096 Nov  6 15:54 public_html
    drwxrwxr-x  5 www-data www-data   4096 Nov  6 15:54 skins
    drwxrwxr-x  2 www-data www-data   4096 Nov  6 15:54 temp
    drwxrwxr-x  7 www-data www-data   4096 Nov  6 15:54 tests
    drwxrwxr-x 13 www-data www-data   4096 Nov  6 16:04 vendor
    
    

    The installer directory:
    Code:
    ls -al
    total 84
    drwxrwxr-x  3 www-data www-data  4096 Nov  6 15:54 .
    drwxrwxr-x 17 www-data www-data  4096 Nov  6 16:09 ..
    -rw-rw-r--  1 www-data www-data  9222 Nov  6 15:54 check.php
    -rw-rw-r--  1 www-data www-data  1655 Nov  6 15:54 client.js
    -rw-rw-r--  1 www-data www-data 22714 Nov  6 15:54 config.php
    drwxrwxr-x  2 www-data www-data  4096 Nov  6 15:54 images
    -rw-rw-r--  1 www-data www-data  6734 Nov  6 15:54 index.php
    -rw-rw-r--  1 www-data www-data  3348 Nov  6 15:54 styles.css
    -rw-rw-r--  1 www-data www-data 16448 Nov  6 15:54 test.php
    
    

    the mail.mydomain.com.conf file:

    Code:
    server {
        listen 80;
        server_name mail.mydomain.com;
        root /var/www/html/roundcube;
    
    
        error_log /var/log/nginx/roundcube.error;
        access_log /var/log/nginx/roundcube.access;
    
    
        location ~ /.well-known/acme-challenge {
          allow all;
        }
       location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
          deny all;
        }
        location ~ ^/(bin|SQL)/ {
          deny all;
        }
       # A long browser cache lifetime can speed up repeat visits to your page
        location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
           access_log        off;
           log_not_found     off;
           expires           360d;
        }
    
    
        index index.php index.html index.htm;
    
    
        location / {
            try_files $uri $uri/ =404;
        }
    
    
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
         }
    
    
        location ~ /\.ht {
            deny all;
        }
    
    
    }



    Please correct me if I'm wrong, I think you should declare the site location folder from the nginx server. This should be inside the nginx.conf
    It should be declared as:
    Code:
    include /sitelocationfolder/*.conf
    What I'm thinking is that the server port declaration is different from the nginx declaration. That's only my opinion. I don't know if it sync on you. I'm asking for an apology for my english.
    I am try to explain further but I'm not that good at it. So Good Luck and Regards.
    corn ubuntuforums community.
    Open Source platform where the real world of human is here. Click here for Solve thread
    Rock n' Roll People.
    From: mike_08

  5. #5
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: 404 Not Found error with nginx

    Bind needs all sorts of manual configuration. Just installing it doesn't do anything.
    You can cheat by modifying the local /etc/hosts files on every system to point to the correct place. That is both on the clients and on the server. With fewer than 5 systems, this is easiest. With more than 5, perhaps running a pi-hole that also does DNS makes sense. In a work environment, a fully configured DNS makes the most sense.

    I don't use roundcube and avoid php-based webapps, so I can't help with it. Sorry.
    For nginx look at the access and error logs. Those are critical.
    Last edited by TheFu; November 10th, 2021 at 05:08 PM.

  6. #6
    Join Date
    Aug 2020
    Location
    Denmark
    Beans
    79
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: 404 Not Found error with nginx

    To me it also sounds like DNS is not configured. Try and do a DNS lookup for the site to see if you get a response:

    Code:
    nslookup mail.mydomain.com
    You should get an output similar to:

    Code:
    Server:         127.0.0.1
    Address:        127.0.0.1#53
    
    Name:    mail.mydomain.com
    Address: your.ip.add.ress
    If not, then DNS is not configured properly.
    Supermicro Server :: Atom C3558 (4) @ 2.2 GHz :: 32 GB DDR4-2400 :: 512 GB NVMe :: 4x 2 TB SSD @ RAID-Z :: 1x Raspberry Pi 4 Server

    Scripts: directory-tools | rsync-backup | add-apt-key

  7. #7
    Join Date
    Dec 2010
    Beans
    405

    Re: 404 Not Found error with nginx

    I've updated my hosts file with the following entries:
    mail 127.0.0.1
    mail.mydomain.com 127.0.0.1

    Upon attempting to load the page, I am confronted with the same 404 error message, as well as in the access log file.
    Last edited by sniper8752; November 11th, 2021 at 08:36 PM.

  8. #8
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: 404 Not Found error with nginx

    That doesn't look correct.

    You need to use the correct format for the /etc/hosts file. There are thousands of example and articles about that on the internet. We don't get to make up whatever format we like.
    Also, 127.0.0.1 or any IP that begins with 127 is only for the localhost. It won't help a client locate any remote server (different machine). It is useful to connect to different servers on the same logical host machine only.

  9. #9
    Join Date
    Dec 2010
    Beans
    405

    Re: 404 Not Found error with nginx

    I've updated the hosts file to be <ip> <hostname> instead.
    It still throws a 404.
    I see this in error.log: 2021/11/11 19:03:22 [warn] 769#769: conflicting server name "mail.mydomain.com" on 0.0.0.0:80, ignored

  10. #10
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: 404 Not Found error with nginx

    Less descriptions.
    More facts. Please post files and CLEARLY say where they are and one which system they are on.
    For example, the client system (running a browser) doesn't magically know anything about the server /etc/hosts updates. The client machine /etc/hosts file must be updated.

    Basic IP networking. How's your knowledge at that? If weak, best to get the basics down first.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •