[NGINX] ALLOW CORS MULTIPLE DOMAIN - fourslickz/notes GitHub Wiki

server {
        listen 80;
        root /home/USERNAME/domain/public;

        index index.html index.php;

        server_name domain;

        location / {
                #CORS
                if ($request_method = OPTIONS) {
                    return 204;
                }

                add_header Access-Control-Allow-Origin *;
                add_header Access-Control-Allow-Headers *;

                try_files $uri $uri/ /index.php?$query_string;

        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        }


        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}

        location /pma {
                alias /usr/share/pma;
                index index.php;

                location ~ \.php$ {
                    try_files $uri =404;
                    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                    index index.php;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME $request_filename;
                    include fastcgi_params;
                }
        }

}