How to fix CORS error for amazon s3 files and resources?

Go to bucket

In the bucket permissions tab

There is a section for CORS, put the following in it and save.

[
    {
        "AllowedOrigins": [
            "*"
        ],
        "AllowedMethods": [
            "GET"
        ],
        "MaxAgeSeconds": 3000,
        "ExposeHeaders": [
             "Content-Range",
             "Content-Length",
             "ETag"
        ],
        "AllowedHeaders": [
            "Authorization",
            "Content-Range",
            "Accept",
            "Content-Type",
            "Origin",
            "Range"
        ]
    }
]

centos web panel – vhost templates for proxying websocket traffic

http://wiki.centos-webpanel.com/webservers-vhost-templates

Templates location: /usr/local/cwpsrv/htdocs/resources/conf/web_servers/
– Folder main contains main configuration for WebServers
– Folder vhosts contains vhosts configuration for domains (this is what you need)

How to create a template file
The easiest way to do that is to simply copy an existing file and then edit a new file you have created.
Note that you need to have .tpl and .stpl files (tpl is for http and stpl is for https version)

Let’s do one example for apache vhost with nginx

cd /usr/local/cwpsrv/htdocs/resources/conf/web_servers/vhosts/nginx/
cp default.tpl my-template.tpl
cp default.stpl my-template.stpl

Now you can edit these newly created template files.

Template folders explained
List from folder: /usr/local/cwpsrv/htdocs/resources/conf/web_servers/vhosts/

httpd = apache templates
nginx = nginx templates
varnish = varnish templates
php-fpm = php-fpm service templates (used for all php-fpm versions)

add a block

map $http_upgrade $connection_upgrade {
	default upgrade;
	'' close;
}

also add these inside “location /” block

		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection $connection_upgrade;
		proxy_set_header Host $host;

basic cwp with jenkins and nodejs

hostname srv1.example.com
yum -y install wget
yum -y update
reboot


cd /usr/local/src
wget http://centos-webpanel.com/cwp-el7-latest
sh cwp-el7-latest -r no --phpfpm 7.3 --softaculous no



reboot



sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum upgrade
sudo yum install epel-release java-11-openjdk-devel
sudo yum install jenkins
sudo systemctl daemon-reload
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
sudo yum install nodejs npm -y
sudo npm install [email protected] -g

Ways to block user via .htaccess

#Order deny,allow
#Deny from all
#Allow from 3.92.40.40
#Allow from 4.30.3.0/4
#Allow from 4.30.3.18
#Allow from 4.30.3.15
#Allow from 104.9.55.44

RewriteCond %{REMOTE_ADDR} !^(4\.30\.3\.[0-9]*)$
RewriteCond %{HTTP:X-Forwarded-For} !^(4\.30\.3\.[0-9]*)$
RewriteCond %{REMOTE_ADDR} !^(104\.9\.55\.44)$
RewriteCond %{HTTP:X-Forwarded-For} !^(104\.9\.55\.44)$
RewriteRule ^(.*) - [F]

S3 notes – how to make all s3 images public

aws configure --profile myproject
// to test if it works or not

aws s3 ls --profile myproject

aws s3 cp \
      --exclude "*" \
      --include "*.jpeg" \
      --content-type="image/jpeg"  \
      --metadata-directive="REPLACE" \
      --recursive \
	  --acl public-read \
       s3://myproject/ \
       s3://myproject/ \
	   --dryrun --profile myproject
aws s3 cp \
      --exclude "*" \
      --include "*.jpg" \
      --content-type="image/jpeg"  \
      --metadata-directive="REPLACE" \
      --recursive \
	  --acl public-read \
       s3://myproject/ \
       s3://myproject/ \
	   --dryrun --profile myproject
aws s3 cp \
      --exclude "*" \
      --include "*.jpeg" \
      --content-type="image/jpeg"  \
      --metadata-directive="REPLACE" \
      --recursive \
	  --acl public-read \
       s3://myproject/ \
       s3://myproject/ \
	   --dryrun --profile myproject
// not needed 
aws s3 sync . s3://my-bucket/path --acl public-read
	   

Dont forget to remove dryrun flag once you are sure.

How to fix Magento2 apis not working? fix coupon apis and other PUT OPTIONS APIs

The issue is actually related to your server’s configuration. By default all types of requests are not allowed. Please add the following to your .htaccess file

<Limit GET POST OPTIONS PUT DELETE PROPFIND>
    Order allow,deny
    Allow from all
    Require all granted
</Limit>

CSS Flashy button with glaze effect

.flashybtn
{
    display: block;
    text-align: center!important;
    text-decoration: none!important;
    font-weight: 800!important;
    font-size: 1.5em;
    text-transform: uppercase!important;
    color: #fff!important;
    padding: 1em 0.1em 1em 0.1em!important;
    background-size: 200% auto!important;
    box-shadow: 0 4px 6px rgba(50,50,93,.11),0 1px 3px rgba(0,0,0,.08)!important;
    background-image: linear-gradient(to right,#ff473d 0%,#ff379d 50%,#f13790 100%)!important;
    animation: gradient 1.5s ease infinite!important;
    width: 100%;
    position: relative; //change to fixed to make it sticky
    bottom: 0;
    left:0;
    z-index: 9999;
	}
.flashybtn:before {
    content: "";
    display: inline-block;
    position: absolute;
    background: rgb(255,255,255);
    width: 30px;
    height: 2em;
    left: 0;
    bottom: 0;
    filter: blur(1.5em);
    animation: 2s glaze infinite;
}
@keyframes glaze{
    from{
        transform: translateX(0) skewX(-15deg);
        opacity:1;
        }
    to {
        transform: translateX(100vw) skewX(-15deg);
        opacity:1;
       }
}

I am FLASHY

How to put a site in maintenance? [Apache web server]

ErrorDocument 403 /index.html
DirectoryIndex index.html
<Files ~ "index\.html">
	Order Allow,Deny
	Allow from all
</Files>
Deny from all

Content of your .htaccess file

If you want to whitelist any IP, use this

ErrorDocument 403 /index.html
DirectoryIndex index.html
<Files ~ "index\.html">
	Order Allow,Deny
	Allow from all
</Files>
Order Allow,Deny
Allow from xx.xxx.xx.xx
Deny from all

Here is a sample htaccess for a wordpress website with 1 IP whitelisted 4.129.45.44 and all others are banned. So you only will be able to load the website while everyone else will see contents of index.html with HTTP Status code 403

ErrorDocument 403 /index.html
DirectoryIndex index.php
<Files ~ "index\.html">
    Order Allow,Deny
    Allow from all
</Files>
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^4\.129\.45\.44$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REMOTE_ADDR} !^4\.129\.45\.44$
RewriteRule . /index.php [L]

Allow from 4.129.45.44
Deny from all