Last active
January 20, 2017 13:53
-
-
Save varmil/1527569c2292a348cde84b1a04fe6e79 to your computer and use it in GitHub Desktop.
docker-nginx を vagrant(centos 7)上で動かしたが、mac(ローカルマシン)から接続できず苦戦した話 ref: http://qiita.com/varmil/items/3a93709d935ed2d710d5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nginx: | |
image: nginx:1.10.2-alpine | |
volumes: | |
- ./nginx/nginx.conf:/etc/nginx/nginx.conf | |
- ./nginx/mynginx.cnf:/etc/nginx/conf.d/mysite.template | |
ports: | |
- "8080:80" | |
environment: | |
- NGINX_HOST=127.0.0.1 | |
- NGINX_PORT=80 | |
..... | |
command: /bin/sh -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream backend { | |
server ${NGINX_HOST_SERVER}:1337; | |
} | |
server { | |
listen ${NGINX_PORT}; | |
server_name ${NGINX_HOST}; | |
location ~ .*\.(jpg|gif|png|css|js|inc|ico) { | |
expires 30d; | |
root ${NGINX_WEB_ROOT}; | |
} | |
location / { | |
add_header Access-Control-Allow-Origin '*'; | |
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; | |
add_header Access-Control-Allow-Headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; | |
add_header Access-Control-Allow-Credentials true; | |
expires modified +10m; | |
proxy_pass http://backend; | |
break; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant:~ $ sudo sysctl -w net.ipv4.ip_forward=1 | |
net.ipv4.ip_forward = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment