Skip to content

Instantly share code, notes, and snippets.

@mdestafadilah
Created September 27, 2024 03:44
Show Gist options
  • Save mdestafadilah/29859a923a00d45fc6d2166015aad18c to your computer and use it in GitHub Desktop.
Save mdestafadilah/29859a923a00d45fc6d2166015aad18c to your computer and use it in GitHub Desktop.
Aksara CMS in nginx config
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
add_header X-Permitted-Cross-Domain-Policies "none";
add_header Strict-Transport-Secuirty "max-age=31536000; includeSubDomains; preload";
include /www/server/nginx/conf/idFlorin.conf; # you can remove this line
# sumber: https://github.com/abydahana/aksara/issues/580#issuecomment-2376320598
set $public_dir "/www/path_offyour_aksaracms/public";
# Enforce NO www
if ($host ~* ^www\.(.*)) {
set $host_without_www $1;
rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}
# Removes trailing "index" from all controllers
if ($request_uri ~* index/?$) {
rewrite ^/(.*)/index/?$ /$1 permanent;
}
# Removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
# Unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# Catch all
error_page 404 /index.php;
# Use fastcgi for all php files
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $public_dir/$fastcgi_script_name;
include fastcgi_params;
}
# Deny access to apache .htaccess files
location ~ /\.ht {
deny all;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment