andreapollastri / cipi

Install and manage your server like a pro! With Cipi you don’t need to be a Sys Admin to deploy and manage websites and PHP applications powered by cloud VPS.
https://cipi.andreapollastri.net
1.09k stars 223 forks source link

Default Nginx Config #361

Closed jtoland closed 2 years ago

jtoland commented 2 years ago

Hello,

First of all, this is a really useful project and already set it up on 3 servers so i can test it fully.

But I was wondering if there was a way to update the default Nginx config as the default config you provide is a bit bare.

If this is a thing i would love to know where it is.

Kind Regards, Jason

andreapollastri commented 2 years ago

Hi, Thank You for the issue! You can customize every Site nginx configuration using cipi root user:

This is a "safe" method documented here: https://cipi.sh/docs.html. Anyway, you can also manually edit the main nginx file into your server.

All sites configurations start from this stub: https://github.com/andreapollastri/cipi/blob/master/storage/app/cipi/host.conf. If you have any suggest about it, let me know! ;)

Best Andrea

jtoland commented 2 years ago

Hello Andrea,

Thank you for providing me with an update on this and providing the location.

I usually deploy WordPress sites with the following config but as a feature it would be nice to be able to create my own and then use that to push to certain sites.

server {
   listen 80;
   root /var/www/vhosts/example.com/http;
   index index.php   index.html index.htm index.nginx-debian.html;
   server_name example.com www.example.com;
   #Logs Location
   access_log  /var/www/vhosts/example.com/logs/access.log;
   error_log  /var/www/vhosts/example.com/logs/error.log;
   #Disable Directory Listing
   autoindex off;
   location / {
   try_files $uri $uri/ /index.php?$args;
   }
   location ~* /xmlrpc.php$ {
   #    allow 172.0.1.1;
   deny all;
   }
   if ($request_method !~ ^(GET\|POST)$ ) {
   return 444;
   }  
   location ~* /(?:uploads\|files\|wp-content\|wp-includes\|akismet)/.*.php$ {
   deny all;
   access_log off;
   log_not_found off;
   }
    # Add a slash at the end of request */wp-admin
   rewrite /wp-admin$ $scheme://$host$uri/ permanent; 
   # Deny files starting with a . (dot)
   location ~ /\. {
   deny all;
   }  
   location = /wp-login.php {
   limit_req   zone=one  burst=1 nodelay;
   include fastcgi.conf;
   fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
   }
   # To Make PHP Files Work
   location ~ \.php$ {
   try_files $uri =404;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
   fastcgi_index index.php;
   include fastcgi.conf;
  }  
   }
andreapollastri commented 2 years ago

Hi! I have examinated your configuration and it is very customized on your own needs so I can't put it into the project but you can manually edit your nginx configs via SSH (use cipi user to login).

The configurations are in: /etc/nginx/site-availables /etc/nginx/site-enables

Than you have to restart nginx service.

Best Andrea