Snippets Collections
map $http_origin $allow_origin {
    ~^https?://(.*\.)?my-domain.com(:\d+)?$ $http_origin;
    ~^https?://(.*\.)?localhost(:\d+)?$ $http_origin;
    default "";
}

server {
    listen 80 default_server;
    server_name _;
    add_header 'Access-Control-Allow-Origin' $allow_origin;
    # ...
}
# start a web service using nginx
service nginx start

# check nginx landing page using curl
curl http://localhost:80
server {
  ...
    location /wp {
        alias /home/user/www/.../wordpress/;
        index index.php index.html index.htm;
        try_files $uri $uri/ /wp/index.php?$is_args$args;
    }
    location ~ \.php$ {
        root /home/user/www/.../wordpress/;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_split_path_info ^/wp(/.+\.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

  ...
}
star

Wed Aug 11 2021 14:45:09 GMT+0000 (UTC)

#nginx #cors
star

Sat Apr 10 2021 05:57:14 GMT+0000 (UTC)

#linux #nginx

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension