Can not use local domain with NGINX

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
wmcig
Posts: 39
Joined: Wed Aug 25, 2021 12:17 pm

Can not use local domain with NGINX

Post by wmcig »

Hi,

I deleted the docker environment and using now Pihole, NGINX and PHP via the software center installation.

Now again I wanted to use a local domain with NGINX. But it does not work for me.

I wanna use Grav CMS for a local website. I followed the tutorial on a german website: www.howtoforge.de/anleitung/wie-man-gra ... liert/amp/

Everything worked fine until I used the domain, which was used in the conf file (/etc/nginx/conf.d/grav.conf):

Code: Select all

server {

listen 80;

server_name grav.example.com;
root /var/www/html/grav;

index index.html index.php;

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

   location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
   location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
   location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
   location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }

location ~ \.php$ {
   fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_index index.php;
   include fastcgi_params;
   fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
 }

}
The NGINX installation was very new via the software center.

What can I do?
User avatar
Joulinar
Posts: 6528
Joined: Sat Nov 16, 2019 12:49 am

Re: Can not use local domain with NGINX

Post by Joulinar »

maybe a conflicting configuration. Do you still have the default config file in place?

Code: Select all

cat /etc/nginx/sites-enabled/default
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
wmcig
Posts: 39
Joined: Wed Aug 25, 2021 12:17 pm

Re: Can not use local domain with NGINX

Post by wmcig »

Joulinar wrote: Wed Oct 27, 2021 12:30 am maybe a conflicting configuration. Do you still have the default config file in place?

Code: Select all

cat /etc/nginx/sites-enabled/default

Code: Select all

cat /etc/nginx/sites-enabled/default
#D I E T - P I
# /etc/nginx/sites-available/default

server {

        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www;
        index index.php index.html index.htm index.nginx-debian.html;

        server_name "$hostname";

        include /etc/nginx/sites-dietpi/*.conf;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php(?:$|/) {
                include snippets/fastcgi-php.conf;
                fastcgi_pass php;
        }

}
User avatar
Joulinar
Posts: 6528
Joined: Sat Nov 16, 2019 12:49 am

Re: Can not use local domain with NGINX

Post by Joulinar »

basically you have a similar configuration in 2 different files. I would recommend to place all your stuf into a single file to avoid duplicate and conflicting entries.

Probably best to use /etc/nginx/sites-enabled/default and to adjust to your needs
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
wmcig
Posts: 39
Joined: Wed Aug 25, 2021 12:17 pm

Re: Can not use local domain with NGINX

Post by wmcig »

Joulinar wrote: Wed Oct 27, 2021 12:14 pm basically you have a similar configuration in 2 different files. I would recommend to place all your stuf into a single file to avoid duplicate and conflicting entries.

Probably best to use /etc/nginx/sites-enabled/default and to adjust to your needs
Do you mean that I should change the default conf file and use this instead if grav.conf file?
User avatar
Joulinar
Posts: 6528
Joined: Sat Nov 16, 2019 12:49 am

Re: Can not use local domain with NGINX

Post by Joulinar »

At least you would need to decide which one to keep as both files contains the same parameters, just with different values.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply