File: //etc/nginx/sites-enabled/smarthr-co-in.conf
server {
listen 443 ssl;
server_name smarthr.co.in;
root /mnt/data/smarthr-co-in;
index index.php index.html;
ssl_certificate /etc/nginx/ssl/stardreams.pem;
ssl_certificate_key /etc/nginx/ssl/stardreams.key;
add_header X-Content-Type-Options "nosniff";
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=86400; includeSubDomains";
client_max_body_size 16M;
# =================================================
# CAKEPHP (CORRECT – WEBROOT BASED)
# =================================================
location ^~ /demo/cakephp/ {
alias /mnt/data/smarthr-co-in/demo/cakephp/webroot/;
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ ^/demo/cakephp/.*\.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME /mnt/data/smarthr-co-in/demo/cakephp/webroot$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/demo/cakephp/.*\.(css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf)$ {
alias /mnt/data/smarthr-co-in/demo/cakephp/webroot/;
expires 30d;
access_log off;
}
# =================================================
# PHP STATIC TEMPLATE
# =================================================
location /demo/php/template/ {
try_files $uri $uri/ =404;
}
location ~ ^/demo/php/template/.*\.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# =================================================
# LARAVEL
# =================================================
location ^~ /demo/laravel/template/ {
root /mnt/data/smarthr-co-in;
index index.php;
try_files $uri $uri/ /demo/laravel/template/public/index.php?$query_string;
}
location ~ ^/demo/laravel/template/public/.*\.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# =================================================
# YII 2 BASIC
# =================================================
location ^~ /demo/yii/template/ {
root /mnt/data/smarthr-co-in/demo/yii/template/web;
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ ^/demo/yii/template/.*\.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# =================================================
# CODEIGNITER 4
# =================================================
location ^~ /demo/codeigniter/template/ {
root /mnt/data/smarthr-co-in;
index index.php;
try_files $uri $uri/ /demo/codeigniter/template/public/index.php?$query_string;
}
location ~ ^/demo/codeigniter/template/public/.*\.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# =================================================
# SPA (REACT / VUE / ANGULAR)
# =================================================
location ^~ /demo/react/template/ {
index index.html;
try_files $uri $uri/ /demo/react/template/index.html;
}
location ^~ /demo/vue/template/ {
index index.html;
try_files $uri $uri/ /demo/vue/template/index.html;
}
location ^~ /demo/angular/template/ {
index index.html;
try_files $uri $uri/ /demo/angular/template/index.html;
}
# =================================================
# WORDPRESS (ROOT)
# =================================================
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ ^/index\.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# =================================================
# SECURITY
# =================================================
location ~ /\.(env|ini|log|sh|sql)$ { deny all; }
location ~ /\.git { deny all; }
error_log /var/log/nginx/smarthr-co-in_error.log;
access_log /var/log/nginx/smarthr-co-in_access.log combined;
}