三三世界-百宝箱

文章 分类 标签
132 9 250

公告

暂无站点公告

WHMCS 8.3的伪静态规则For Nginx

三三 2021-11-14 3691 0条评论 服务器配置环境搭建 WHMCS伪静态规则NginxRewrite

首页 / 正文

whmcs软件安装后,一切运行正常的情况下,可以来调试伪静态规则。
这里的环境是使用ssl证书的whmcs平台,同时使用的是nginx(apache的平台直接修改.htaccess文件即可实现),
注意,Nginx需要修改whmcs网站的niginx conf文件。
如果使用的是lnmp,存储目录为: /usr/local/nginx/conf/vhost/xxx.com.conf
如果不是lnmp,一般存储目录为:/etc/nginx/conf.d/default.conf 具体根据您服务器情况判定。
在网站规则部分加入下面代码:


管理区域伪静态规则 /whmcs/admin是管理目录

  location ~ /whmcs/admin/(client!\.php|client/(.*)|search!\.php|search/(.*)|apps|billing|setup|user|services|addons|domains|utilities|logs|help!\.php|help/license|image/(recent|upload))/?(.*)$ {
    root /path/to/website/root/folder;
    rewrite ^/(.*)$ /whmcs/admin/index.php?rp=/admin/$1/$2;
  }

#== 客户区域伪静态规则

  location ~ /whmcs/(images/em|invoice|login|password|account|store|download|knowledgebase|project_management|announcements|clientarea/ssl-certificates|user/(verification|accounts|profile|password|security|verify)|cart/(domain/renew)|cart/order|images/kb)/?(.*)$ {
    root /path/to/website/root/folder;
    rewrite ^/(.*)$ /whmcs/index.php?rp=/$1/$2;
  }

具体情况根据你的网站目录进行微调。有问题可以在下方留言,会尽量帮您指出问题。


下面是整理的其他版本的伪静态规则,可以作为参考:

1、其他版本的conf代码参考(for whmcs 8.x),下面是ssl版本的,一样是修改网站的conf文件:

server {
    listen 80 default_server;
    server_name 33f.net www.33f.net;
    return 301 https://33f.net$request_uri;
}

# HTTPS server
#
server {
    listen 443;
    server_name 33f.net;
    root /var/www/html/public;
        access_log /var/log/nginx/33f.net-access_log;
        error_log /var/log/nginx/33f.net-error_log;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

    index index.php index.html index.htm;

    charset utf-8;

    ssl on;
    ssl_certificate /var/www/html/storage/ssl/cert.pem;
    ssl_certificate_key /var/www/html/storage/ssl/cert.key;

    ssl_session_timeout 5m;

    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
    ssl_prefer_server_ciphers on;


    location ~ /clients/admin/(client!\.php|search|apps|billing|setup|user|services|addons|domains|utilities|help!\.php|help/license|image/(recent|upload))/?(.*)$ {
        rewrite ^/(.*)$ /clients/admin/index.php?rp=/admin/$1/$2;
    }

    location ~ /clients/(login|password|account|store|download|knowledgebase|announcements|clientarea/ssl-certificates|user/(profile|password|security)|cart/(domain/renew)|images/kb)/?(.*)$ {
                rewrite ^/(.*)$ /clients/index.php?rp=/$1/$2;
    }


    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    
    error_page 404 /index.php;


    proxy_send_timeout 300s;
    proxy_read_timeout 300s;

    
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        fastcgi_send_timeout 300;
            fastcgi_read_timeout 300;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
    
    location ~ /\.(?!well-known).* {
        deny all;
    }

    
    location ^~ /clients/vendor/ {
            deny all;
        return 403;
    }
    
    location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|svg|woff|woff2|ttf)\$ {
        expires 1M;
        access_log off;
            add_header Cache-Control "public";
    }
    
    location ~* \.(?:css|js)\$ {
            expires 7d;
            access_log off;
            add_header Cache-Control "public";
    }
    
    location ~ /\.ht {
        deny  all;
    }
}

2、下面是非ssl版本的conf配置文件,也可以参考一下,注意啊,原则是尽量在你的conf基础上查缺补漏

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;
    }
}

3、下面是whmcs 7.x版本的伪静态,8.x的一样可以参考

同样更新.conf文件。

# WHMCS客户中心区域

    location ~ /billing/announcements/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/announcements/$1;
    }
    location ~ /billing/download/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/download$1;
    }
    location ~ /billing/knowledgebase/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/knowledgebase/$1;
    }
    location ~ /billing/store/ssl-certificates/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/store/ssl-certificates/$1;
    }
    location ~ /billing/store/sitelock/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/store/sitelock/$1;
    }
    location ~ /billing/store/website-builder/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/store/website-builder/$1;
    }
    location ~ /billing/store/order/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/store/order/$1;
    }
    location ~ /billing/cart/domain/renew/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/cart/domain/renew$1;
    }
    location ~ /billing/account/paymentmethods/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/account/paymentmethods$1;
    }

    location ~ /billing/password/reset/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/password/reset/$1;
    }
    location ~ /billing/account/security/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/account/security$1;
    }
    location ~ /billing/subscription?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/subscription$1;
    }

#社交媒体授权
    location ~ /billing/auth/provider/google_signin/finalize/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=auth/provider/google_signin/finalize$1;
    }

 #WHMCS 管理区域
location ~ /billing/admin/(addons|apps|search|domains|help\/license|services|setup|utilities\/system\/php-compat)(.*) {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/admin/$1$2 last; 
    }
    location ~ /billing/admin/client/?(.*)/paymethods/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/client/?(.*)/paymethods/$1;
    }
    location ~ /billing/admin/setup/auth/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/setup/auth/$1;
    }
    location ~ /billing/admin/client/?(.*)/tickets/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/client/?(.*)/tickets/$1;
    }
    location ~ /billing/admin/client/?(.*)/invoice/?(.*)/capture/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/client/?(.*)/invoice/?(.*)/capture/$1;
    }
    location ~ /billing/admin/account/security/two-factor/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/admin/account/security/two-factor/$1;
    }
    location ~ /billing/admin/search/intellisearch?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/search/intellisearch/$1;
    }

# Security Advisory 2020-01-28
    location ^~ /vendor/ {
        deny all;
        return 403;
    }

1、不在billing目录的,自行修改目录

2、如果直接用主域名或者二级域名的,直接可以把"/billing/"替换为"/"就行了,比如:

location ~ /announcements/?(.*)$ {
    rewrite ^/(.*)$ /index.php?rp=/announcements/$1;
}

3、如果管理目录不是/admin,那就直接修改/admin为你自己的管理目录/xxx,比如:

location ~ /billing/目录名/setup/auth/?(.*)$ {
    rewrite ^/(.*)$ /billing/目录名/index.php?rp=/setup/auth/$1;
}

以上基本上就够用了。不懂的可以留言交流。

评论(0)

当前没有评论,还不快来留下第一个脚印吧



最新评论

  • 三三

    @Doug Shume it's ok for me , you can post here.

  • refugiaguenther

    Saved as a favorite, I like your website!

  • josefa

    If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.

  • Penzu

    Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!

  • Yupoo Fendi

    Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.

  • Doug Shume

    Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.

  • SuperWind

    zh.us.to 有效
    kms.03k.org 有效
    kms.chinancce.com
    kms.shuax.com 有效
    kms.dwhd.org 有效
    kms.luody.info 有效
    kms.digiboy.ir 有效
    kms.lotro.cc 有效
    www.zgbs.cc 有效
    cy2617.jios.org 有效

  • 三三

    @         权限问题,试试sudo 再加命令。

  •         

    你好提示Permission denied 怎么办啊

日历

2024年12月

1234567
891011121314
15161718192021
22232425262728
293031    

文章目录

上一张 下一张