TransWikia.com

Apache2.4 and WSL2 is giving an Error 403

Ask Ubuntu Asked by kneeki on December 21, 2021

Problem:

The website is returning an Error: 403 when trying to access it. No information is being given in log files afaik.

Version

Windows 10: Version 2004 (OS Build 19041.388)
WSL: Version 2
Server version: Apache/2.4.41 (Ubuntu)
Server built:   2020-04-13T17:19:17

Permissions

drwxrwxr-x  3 www-data www-data 4096 Jul 22 12:36 /var/www/
lrwxrwxrwx  1 www-data www-data   27 Jul 22 12:36 /var/www/website -> /mnt/d/work/website/
drwxrwxrwx  1 www-data www-data 4096 Jul 22 11:00 /mnt/d/work/website/

Apache2ctl -S

VirtualHost configuration:
*:80                   website.localhost (/etc/apache2/sites-enabled/website.conf:1)
*:443                  website.localhost (/etc/apache2/sites-enabled/website.conf:10)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

VirtualHost Config

<VirtualHost _default_:80>
    ServerName www.website.local
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    DocumentRoot /mnt/d/work/website/public
        
    <Directory /mnt/d/work/website/public>
        RewriteEngine On
        RewriteRule ^public.html$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . public.html [L]

        Options Indexes FollowSymLinks Includes
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

Hosts file

127.0.0.1       www.website.local

Logs

No entries in access.log or error.log???

2 Answers

Update 24-02-2021

ip address of wsl-linux are dynamic ip it will not work. You just need to add two lines of code

127.0.0.1   www.website.local
::1         www.website.local

I also face same issue, Step to fix this issue are pretty simple.

  1. Run command

    $ ip a

    enter image description here

copy ip address 2. press window button type notepad (run as administrator) 3. In notepad, File->open file C:WindowsSystem32driversetchost 4. add line at bottom

172.19.170.24  www.website.local

I try to change /etc/hosts file with both 127.0.0.1 <my_vhost> and 172.19.170.24 <my_vhost>, but that didn't worked.

Answered by sorabh86 on December 21, 2021

I was experiencing the same issue. It's a network error.

Run the ip addr command and find out your eth0 IP address, and use that one for your hosts file.

That's what worked for me, because just like your Apache configuration, mine was right as well.

Answered by Ivan Montilla Miralles on December 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP