Understanding Error 403 Forbidden
Error 403 Forbidden can be triggered by many things, and in this wiki we will show you most of them. The most important thing is to check the log files when you get the error, as they will show the cause in most cases.
Generally, it is not LiteSpeed Web Server causing 403 issues. Most of the time, the error is related to a permission issue, configuration restriction, security settings, mod_security etc.
If you use a control panel like cPanel, you can try to switch to Apache and see if the error continues. If it happens to both Apache and LSWS, you can try the following possible tips yourself to locate the root cause. If it doesn't happen to Apache but only happens to LSWS, you can log a ticket with us to take a further look.
File/Directory Permissions
If the file or directory has the wrong permissions, you may see Error 403. Fix the premissions, and the error goes away.
Wrong File/Directory User
Make sure that the file or directory belongs to the correct user. Lets say that your public_html
directory is owned by the username test
, and you try to create a file index.php
as user test1
. That can trigger the error, as test1 will not have permission to read the file or the directory.
Deny From .htaccess File
Your .htaccess
may have code like this:
deny from all
or
deny from <your ip address>
This means that access for the website is denied for everyone, or just from your IP address, respectively. You can simply remove or comment the line out with #
.
Rewrite rule forbidden
If you have something similar to the following rewrite rules, it may return 403 borbidden.
RewriteCond (SOMECONDITION) RewriteRule ^(.*)$ – [F,L]
Indexes
Directory indexing may be preventing a list of the files for the directory, but if you do not have an index file (index.php
, index.html
, etc.) and the autoindex option is ON
that will return error 403.
If you have this line in the .htaccess
file:
Options -Indexes
Remove the line, or turn autoindex on:
Options +Indexes
Problem/Missing PHP Handler
If the PHP handler is not setup correctly, the web server will return error 403. This will be shown in the server error log file and you will need to check it for more information. After that, create the correct PHP handler to resolve the issue.
File Restriction
In Litespeed WebAdmin > Configuration > Server > Security there is an option called Restricted Permission Mask. If you set this to a high value like 644
, you will get error 403 for your pages.
To resolve it you need to lower the value.
Incorrect File Ownership After Migration
When migrating or uploading files to a cPanel account, some image files might incorrectly be assigned to nobody:nobody
, when they should be user:user.
/home/jsmith/public_html>ls -ald images/detailed/130/Untitled-1-Recovered_urba-uz.jpg -rw-rw-rw- 1 nobody nobody 103609 Apr 12 11:21 images/detailed/130/Untitled-1-Recovered_urba-uz.jpg /home/jsmith/public_html>ls -ald images/detailed/130 drwxrwxrwx 2 nobody nobody 36864 Apr 14 15:12 images/detailed/130 /home/jsmith/public_html>ls -ald images/detailed drwxrwxrwx 51 jsmith jsmith 4096 Apr 11 13:16 images/detailed /home/jsmith/public_html>ls -ald images drwxrwxrwx 48 jsmith jsmith 4096 Mar 31 16:30 images
The Force Strict Ownership setting in LSWS Admin specifies whether to enforce strict file ownership checking. If it is enabled, the web server will check if the owner of the file being served is the same as the owner of the virtual host. If it is different, a 403 Access Denied
error will be returned.
To fix the problem, either change all files user:group to user:user ( in the above example, that would be jsmith:jsmith
), or disable Force Strict Ownership in LSWS Admin.
Mod Security/WAF/fail2ban/CPHulk
Depending on what and how many requests you are doing for a particular website, the firewall can block you. In most cases your IP address will be denied in the system firewall (iptables, firewalld etc) and you need to remove your IP address in order to avoid the error.
If mod_security rules enabled, it may be triggerred for 403 error. For example:
[modsecurity] [Fri Apr 26 10:07:36 2019] [error] [client 111.111.111.111] ModSecurity: Access denied with code 403, [Rule: 'TX:ANOMALY_SCORE' '@ge %{tx.in_example_score_threshold}'] [id "949110"] [msg "Inbound Anomaly Score Exceeded (Total Score: 10)"] [severity "CRITICAL"] [tag "application-multi"] [tag "language-multi"][tag "platform-multi"] [tag "attack-generic"]
Hit LiteSpeed Per Client Throttling connection limit
Similar to the previous case - if you have strict throttling rules and you make too many connections, that can trigger error 403.
For example, you may use LiteSpeed per client throttling
throttling feature and set Connection Soft Limit
and Connection Hard Limit
. If any visitor's IP goes over that connection limit, it will trigger 403 error and show the following in the logs:
[NOTICE] [x.x.x.x] bot detected for vhost [N/A], reason: OverConnSoftLimit, close connection
or
[NOTICE] [x.x.x.x] bot detected for vhost [N/A], reason: OverConnHardLimit, close connection!
Hit reCAPTCHA security feature
If a visitor fails on reCAPTCHA verification, it may trigger 403 error.
Hit LiteSpeed WordPress Protection feature
If a visitor hit LiteSpeed WordPress Protection feature with over limit connections, it may trigger 403 error.
GeoIP/IP2Loc or Similar Modules
If GeoIP or IP2Loc is allowed, they can block access to files like wp-login
(wp-admin). In this case you need to allow them access in order to avoid the error.
Error 403 in LiteSpeed WebAdmin
There is an option to restrict access to the WebAdmin. If you forget to add your IP address, or if it changes, you can edit it from the configuration file in /usr/local/lsws/admin/conf/admin_config.xml
:
<security> <accessControl> <allow>XXX.XXX.XXX.XXX</allow> <deny>ALL</deny> </accessControl> </security>
Put your IP address in the allow list. For multiple IP addresses it looks like this:
<allow>XXX.XXX.XXX.XXX, XXX.XXX.XXX.XXX</allow>
Additional Information
The best way to diagnose and resolve that error is to check the system configuration, website configuration and the error logs. If you are unsure what is the correct configuration for some option that is triggering error 403, you can check the wiki for that option.
For example: For GeoLocation configuration or IP2Location.