Hi,
I have bought this domain --> https://www.cdnwknet.com/ to be my cookie free domain. I would like to serve static content from it.
All I need to do is to set it up correctly. At the moment it does not work as I want it to work. I have put images on that domain which can be viewed here --> https://www.cdnwknet.com/img/index.php. I am only displaying the images in that folder of IMG using scandir
so the images are in that folder on that domain.
I tested to call the images from my site --> https://www.damircalusic.se/portfolio/ and than I ran GTMETRIX to see if they are served as static images but they were not as you can see in this report --> http://gtmetrix.com/reports/www.damircalusic.se/YGFX2COr and under YSLOW, CDN.
So my simple question is: How do I config the cdnwknet.com domain?
I would really appreciate any help with this!
My config looks like this at the moment:
server {
listen 80;
listen [::]:80;
server_name cdnwknet.com www.cdnwknet.com;
add_header Strict-Transport-Security max-age=15768000;
return 301 https://www.cdnwknet.com$request_uri;
}
server {
listen 443 ssl;
server_name cdnwknet.com;
ssl_certificate /etc/nginx/ssl/bundle.crt;
ssl_certificate_key /etc/nginx/ssl/KEY.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;
ssl_prefer_server_ciphers on;
return 301 https://www.cdnwknet.com$request_uri;
}
server {
listen 443 ssl;
server_name www.cdnwknet.com;
root /var/www/cdnwknet.com/html;
index index.php index.html index.htm;
ssl_certificate /etc/nginx/ssl/bundle.crt;
ssl_certificate_key /etc/nginx/ssl/KEY.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;
ssl_prefer_server_ciphers on;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
charset utf-8;
if ( $request_uri ~ ^(/index\.php)$ ) {
return 301 https://www.cdnwknet.com;
}
location / {
try_files $uri $uri/ =404;
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
access_log off;
log_not_found off;
fastcgi_hide_header Set-Cookie;
tcp_nodelay off;
break;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location = /error/403.html {
root /var/www/cdnwknet.com/html;
allow all;
}
location = /error/404.html {
root /var/www/cdnwknet.com/html;
allow all;
}
}
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
This question was answered by @EpicCDN:
What you mean by scandir? you mean php scandir function? why you need to show images directory tree? why you need to run PHP on a Static CDN at all?
here is a simple CDN conf example, change as you need:
server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /data-ebs/websites/somesite/public_html; index cdn-redirect.html; # Make site accessible from http://localhost/ server_name .somedomain.com; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { return 200 "User-agent: *\nDisallow: /"; } #Redirect to main website if someone just enters the domain root location / { if ($host !~* ^(www)) { rewrite ^/(.*)$ $scheme://www.somadomain.com/$1 permanent; } } location ~* ^.+\.(js|css)$ { access_log off; log_not_found off; } location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { add_header Access-Control-Allow-Origin *; access_log off; log_not_found off; expires max; } }
What you mean by scandir? you mean php scandir function? why you need to show images directory tree? why you need to run PHP on a Static CDN at all?
here is a simple CDN conf example, change as you need:
Hi, I cannot see any error about this. Are my settings correct above according to you? Do I need to change some DNS settings aswell?
Hi! Do you see any errors in nginx’s error log?