RTippin / messenger

Laravel messenger. A full messenger suite for your new / existing laravel app! Private and group threads between multiple models, with real-time messaging, reactions, attachments, calling, chat bots, and more!
https://tippindev.com
MIT License
416 stars 84 forks source link

How to fix this 403 Forbidden Permission to access Error in my case ? #37

Closed chegmarco1989 closed 2 years ago

chegmarco1989 commented 2 years ago

Hi.

Unable to connect to my site (https://msg.worklx.com/) Laravel, I get the error: Forbidden You don’t have permission to access this resource.

IMPORTANT: I specify that I cloned and indeed installed via "composer" all the dependencies of the Demo Version of RTippin/messenger (https://github.com/RTippin/messenger-demo) and even installed the components of the Demo in question via php artisan demo:install.

So how to fix it ??? I really need your help.

ajnozari commented 2 years ago

This sounds like a config issue in your environment not the package itself. Please double check that your Nginx/Apache config is correct and that the USER the web server is running as has permission to the folders you're running the app from.

you can check this with ls -al

on your web server, it will list the user and group that has permission to the folder, as well as relevant permissions. You'll see something like this:

Screen Shot 2022-01-19 at 2 57 27 PM

If you see that the files aren't owned by the appropriate user (usually www-data on most Linus distress) you can use the chmod command to correct this.

chegmarco1989 commented 2 years ago

Thank you @ajnozari for your reply. But here is the result of my screenshot when I do ls -al in the public_html directory:

WorkLx MSG Server Command

So where is the error (403 Forbidden You don't have permission to access this resource) preventing normal from my site according to you ???

And how to fix it to make my site work normally ???

It's a puzzle for me. I really need help.

RTippin commented 2 years ago

That "error" is not coming from my package/demo at all. It seems your apache/nginx is not operating under the proper permissions to access your webservers files. As noted above, you should probably check both the webserver itself, and the directories/permissions to ensure the proper user/group and read/write access permissions. It is typical to use a www-data group your webserver runs as. Example docker setup:

COPY --chown=www-data:www-data . /var/www/html
RUN find /var/www/html -type f -exec chmod 644 {} \;
RUN find /var/www/html -type d -exec chmod 755 {} \;
ajnozari commented 2 years ago

Closed due to environment issue not package issue

RTippin commented 2 years ago

Just to add a note, your document root is pointing to the main public_html directory, meaning your .env file, among other things, are exposed. Your webservers root should serve from the public directory where the index.php files is located. All web traffic is directed through there, and should never have access to your leading project directory.

Notice the "site" that is viewable through Your Public Directory should be where your webserver is always pointed as the root directory.

https://laravel.com/docs/8.x/structure#the-public-directory https://laravel.com/docs/8.x/installation#directory-configuration

chegmarco1989 commented 2 years ago

Obviously there is a problem on the system configuration side but there is also and above all a problem with the DEMO page because finally, I discovered that the link works here: https://msg.worklx.com/public/index.php.

But, impossible to access it directly via: https://msg.worklx.com.

So the question is: _Why is the web app in a sub folder under root named ‘public’ and not simply under publichtml - or am I missing something obvious.

So what do you advise me to do about it to finally allow direct access via https://msg.worklx.com/ instead of https://msg.worklx.com/public/index.php ???

chegmarco1989 commented 2 years ago

Notice the "site" that is viewable through Your Public Directory should be where your webserver is always pointed as the root directory.

So, how to fix it very easily because I don't understand what you mean ???

Should I create a new "public" directory in the WebServer root, Web Application files in "public_html" and save them in the new newly created "public" directory in the WebServer root ???

RTippin commented 2 years ago

For apache, you typically need to instruct the virtual host to point to the var/www/public_html/public, eg:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/public_html/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

https://www.interserver.net/tips/kb/deploy-laravel-project-apache-ubuntu/