I'm currently trying to setup a local dev machine with docker, using nginx. I recently switched from Virtualbox support to Hyper-v, and since then I get a 403 Forbbiden in Nginx.
I'm following this tutorial to set up things http://tech.osteel.me/posts/2015/12/18/from-vagrant-to-docker-how-to-use-docker-for-local-web-development.html
My Nginx config is as follows
server {
listen 80 default_server;
root /var/www/html;
index index.html index.php;
charset utf-8;
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; }
access_log off;
error_log /var/log/nginx/error.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}
And my docker-compose
nginx:
build: ./nginx/
ports:
- 80:80
links:
- php
volumes_from:
- app
php:
build: ./php/
expose:
- 9000
links:
- mysql
volumes_from:
- app
app:
image: php:7.0-fpm
volumes:
- ~/docker:/var/www/html
#also tried .:/var/www/html
#and ./docker:/var/www/html
command: "true"
mysql:
image: mysql:latest
volumes_from:
- data
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: project
MYSQL_USER: project
MYSQL_PASSWORD: project
data:
image: mysql:latest
volumes:
- /var/lib/mysql
command: "true"
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- 8080:80
links:
- mysql
environment:
PMA_HOST: mysql
Docker folder is inside my C:/User/docker
What's the catchup here? Thanks
Verify that index.html
or index.php
exists in your C:/User/docker
folder as if that doesn't exist, you will see 403 forbidden as by default you cannot browse the directory.
Then try the following in your docker-compose:
volumes:
- /C/User/docker:/var/www/html
Hope it helps.
A stable dockerfile and image is available on the port of Docker's open source to Windows by WinDocks. WinDocks runs on all editions of Windows 8, 10, Server 2012 and 2016. The 1.04 release includes support for Tomcat, Jetty, Nginx, and Node.js. Free Community edition is Here
Disclosure: I am the Co-Founder of WinDocks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.