server {
    listen 192.168.1.2:80;
    server_name	club3d.ro www.club3d.ro	www.123.club3d.ro www.456.club3d.ro	123.club3d.ro	456.club3d.ro;
    charset	utf-8;
    root /var/www/html/vhosts/club3d.ro/;
    index index.php index.html index.htm; 

    access_log /var/log/nginx/club3d.ro.access.log;
    error_log /var/log/nginx/club3d.ro.error.log;

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

   
   location /madalin {
	  autoindex on;
   }

   location /glibc {
		autoindex on;
   }

   # gzip should not be used with SSL
   gzip off;
   
   location /sgwi {
        auth_basic "Private Zone";
        auth_basic_user_file /etc/nginx/.htpasswd;
   }

   location /anaf {
		auth_basic "Private";
		auth_basic_user_file /etc/nginx/.anaf;
   }

   listen 192.168.1.2:443 ssl http2; # managed by Certbot
   ssl_certificate /etc/letsencrypt/live/club3d.ro-0001/fullchain.pem; # managed by Certbot
   ssl_certificate_key /etc/letsencrypt/live/club3d.ro-0001/privkey.pem; # managed by Certbot
   include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

   ### redirect
   if ($scheme != "https") {
	 return 301 https://$host$request_uri;
   } # managed by Certbot

	if ($host ~* ~^www\..+\.club3d.ro\.ro$) {
    	return 301 $scheme://+\/club3d.ro$request_uri;
	}

}
