worker_processes auto;
events {
        multi_accept on;
        worker_connections 1024;
}


http {
        charset utf-8;
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        types_hash_max_size 4096;
        types_hash_bucket_size 64;
        server_tokens off;
        client_max_body_size 0M;
        set_real_ip_from 192.168.1.31;

        # MIME
        include mime.types;
        default_type application/octet-stream;

        # Log Format
        log_format cloudflare '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $http_cf_ray $http_cf_connecting_ip $http_x_forwarded_for $http_x_forwarded_proto $http_true_client_ip $http_cf_ipcountry $http_cf_visitor $http_cdn_loop';

        # Logging
        access_log /var/log/nginx/access.log cloudflare;
        error_log /var/log/nginx/error.log warn;

        # Load configs
        include /etc/nginx/conf.d/*.conf;

        keepalive_timeout 65;

        server {
                listen 80;
                # This is the URL where we will upload images to
                server_name upload.lovinator.space;
                root /usr/share/nginx/html;
                # discord-embed needs to be running before we can use it
                location / {
                        proxy_pass http://unix:/run/discord-embed.sock;
                }

                # logging
                access_log /var/log/nginx/lovinator.space.access.log cloudflare;
                error_log /var/log/nginx/lovinator.space.error.log warn;

                # favicon.ico
                location = /favicon.ico {
                        log_not_found off;
                        access_log off;
                }

                # robots.txt
                location = /robots.txt {
                        log_not_found off;
                        access_log off;
                }

                # gzip
                gzip on;
                gzip_vary on;
                gzip_proxied any;
                gzip_comp_level 6;
                gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
        }

        server {
                listen 80;
                # This is the URL that the images will be served from
                server_name i.lovinator.space;

                # Where the images and videos are stored. Should be the same as "Environment="DOMAIN=https://i.lovinator.space/"" in discord-embed.service
                root /Uploads;
                location / {
                        try_files $uri $uri/ $uri.html;
                }

                # logging
                access_log /var/log/nginx/lovinator.space.access.log cloudflare;
                error_log /var/log/nginx/lovinator.space.error.log warn;

                # favicon.ico
                location = /favicon.ico {
                        log_not_found off;
                        access_log off;
                }

                # gzip
                gzip on;
                gzip_vary on;
                gzip_proxied any;
                gzip_comp_level 6;
                gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
        }

}