Created
February 23, 2018 08:22
-
-
Save Bharat-B/62205bfd1dbe6d7ac9e24973c2bfd47e to your computer and use it in GitHub Desktop.
WHMCS nGINX rules for SSL / Non SSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### NON SSL | STANDARD HTTP | |
server { | |
listen 80; | |
server_name domain.com; | |
root /path/to/whmcs; | |
index index.php index.html; | |
access_log /var/log/nginx/domain.com.log combined; | |
access_log /var/log/nginx/domain.com.bytes bytes; | |
error_log /var/log/nginx/domain.com.error.log error; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ { | |
expires max; | |
} | |
location ~ [^/]\.php(/|$) { | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
if (!-f $document_root$fastcgi_script_name) { | |
return 404; | |
} | |
fastcgi_pass unix:/path/to/php-fpm.sock; | |
fastcgi_index index.php; | |
include /etc/nginx/fastcgi_params; | |
} | |
} | |
location ~ /announcements/?(.*)$ { | |
rewrite ^/(.*)$ /index.php?rp=/announcements/$1; | |
} | |
location ~ /downloads/?(.*)$ { | |
rewrite ^/(.*)$ /index.php?rp=/downloads/$1; | |
} | |
location ~ /knowledgebase/?(.*)$ { | |
rewrite ^/(.*)$ /index.php?rp=/knowledgebase/$1; | |
} | |
error_page 403 /error/404.html; | |
error_page 404 /error/404.html; | |
error_page 500 502 503 504 /error/50x.html; | |
location ~* "/\.(htaccess|htpasswd)$" { | |
deny all; | |
return 404; | |
} | |
} | |
### | |
### SSL | SECURE HTTPS | |
server { | |
listen 443 | |
server_name domain.com; | |
root /path/to/whmcs; | |
index index.php index.html; | |
access_log /var/log/nginx/domain.com.log combined; | |
access_log /var/log/nginx/domain.com.bytes bytes; | |
error_log /var/log/nginx/domain.com.error.log error; | |
ssl on; | |
ssl_certificate /path/to/ssl.pem; | |
ssl_certificate_key /path/to/ssl.key; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ { | |
expires max; | |
} | |
location ~ [^/]\.php(/|$) { | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
if (!-f $document_root$fastcgi_script_name) { | |
return 404; | |
} | |
fastcgi_pass unix:/path/to/php-fpm.sock; | |
fastcgi_index index.php; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_read_timeout 30; | |
} | |
} | |
location ~ /announcements/?(.*)$ { | |
rewrite ^/(.*)$ /index.php?rp=/announcements/$1; | |
} | |
location ~ /downloads/?(.*)$ { | |
rewrite ^/(.*)$ /index.php?rp=/downloads/$1; | |
} | |
location ~ /knowledgebase/?(.*)$ { | |
rewrite ^/(.*)$ /index.php?rp=/knowledgebase/$1; | |
} | |
error_page 403 /error/404.html; | |
error_page 404 /error/404.html; | |
error_page 500 502 503 504 /error/50x.html; | |
location ~* "/\.(htaccess|htpasswd)$" { | |
deny all; | |
return 404; | |
} | |
} | |
### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks.
A semicolon is missing at the end of line 52.