Good afternoon,
I try to create a project with Docker and php:7.4-apache image. My development environment has been install (docker-compose & composer install
) without problems but when I try to access to the website from my web browser, I get a HTTP 403 response.
This is my vhost.conf for the website:
<VirtualHost *:80>
DocumentRoot /var/www/html/public
DirectoryIndex /index.php
<Directory /var/www/html>
AllowOverride None
Order Allow,Deny
Allow from All
FallbackResource /index.php
</Directory>
ErrorLog ${APACHE_LOG_DIR}/errors.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The application is on a custom network on Docker :
[{
"Name": "common",
"Id": "302304f6956efb53dad1499ed44394f90a78ad4375d2e2e11b9cda5e8ae76c5e",
"Created": "2022-08-18T21:04:44.8239617Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.19.0.0/16",
"Gateway": "172.19.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"69f7691d8ccd4b36d6ebab6d731ccef7388967ca7bce12c42c2b113f0d5f259d": {
"Name": "postgres-alpine-144_postgres_1",
"EndpointID": "82eba6f54ec7a19ddb072b599e7aa6200b54510affe6b60dfaa90ac4f6344219",
"MacAddress": "02:42:ac:13:00:02",
"IPv4Address": "172.19.0.2/16",
"IPv6Address": ""
},
"fda67c4efa016926b164505ff022d979e7f3a368cfb78098675e8a182f0be639": {
"Name": "api",
"EndpointID": "7e2cfb1d998cef35c22f55eac3a14cdd27eecba211b8233633f9c8dcb5719ff8",
"MacAddress": "02:42:ac:13:00:03",
"IPv4Address": "172.19.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}]
When I check authorizations in public directory:
root@fda67c4efa01:/var/www/html/public# ls -la
total 0
drwxr-xr-x 1 root root 4096 Aug 18 21:58 .
drwxrwxrwx 1 root root 4096 Aug 18 22:00 ..
-rw-r--r-- 1 root root 199 Aug 18 21:38 index.php
root@fda67c4efa01:/var/www/html/public#
And I have added "my-project" to host file.
CodePudding user response:
I have found the solution.
In my Dockerfile, I had this line :
COPY .docker/apache2/vhost.conf /etc/apache2/sites-available/0000-default.conf
I have changed it to :
COPY .docker/apache2/vhost.conf /etc/apache2/sites-available/000-default.conf
It is working perfectly. The problem was probably that I wasn't overriding the default Apache2 configuration