server {
    listen 80;
    server_name maxmarineelectronics.wojodesign.com;

    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    location / {
        return 301 https://$host$request_uri;
    }

    location = /contact {
        return 301 /contact-us;
    }
}



server {
    listen 443 ssl;
    server_name maxmarineelectronics.wojodesign.com;
    
    ssl_certificate /etc/letsencrypt/live/maxmarineelectronics.wojodesign.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/maxmarineelectronics.wojodesign.com/privkey.pem;
    
    root /var/www/html;
    index index.php;

    client_max_body_size 64M;

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

    location ~ \.php$ {
        fastcgi_pass wordpress:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

     # Static files handling
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
        access_log off;
        expires max;
        log_not_found off;
        # Add this to ensure files are found
        try_files $uri $uri/ =404;
    }

    location = /contact {
        return 301 /contact-us;
    }

    # For WordPress admin
    location /wp-admin {
        try_files $uri $uri/ /index.php?$args;
    }
}