Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@190ikp
Last active December 12, 2018 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 190ikp/a0cdca016f2e090f73b150f5c95b8b9b to your computer and use it in GitHub Desktop.
Save 190ikp/a0cdca016f2e090f73b150f5c95b8b9b to your computer and use it in GitHub Desktop.
examples of docker-compose & nginx.conf for KCS article
version: '3'
services:
web:
container_name: web
image: nginx:mainline-alpine
ports:
- 80:80
- 443:443
volumes:
- /vagrant/nginx.conf:/etc/nginx/nginx.conf:ro
- /vagrant/log/nginx:/var/log/nginx
- /vagrant/www:/var/www:ro
<html>
<body>
Hello World
</body>
</html>
user nginx;
worker_processes auto;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
charset UTF-8;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
error_log /var/log/nginx/error.log warn;
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 45;
gzip on;
# gzip_vary on;
gzip_proxied any;
gzip_comp_level 2;
gzip_min_length 3k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_static on;
# include /etc/nginx/conf.d/*.conf;
# このように証明書を設定すればHTTTPSも使える
# server.keyとserver.crtは自分で用意
# ssl_protocols TLSv1.2;
# ssl_certificate server.crt;
# ssl_certificate_key server.key;
# add_header Strict-transport-Security "max-age=31536000; includeSubdomains";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header Host $host;
server {
listen 80;
server_name default_server;
root /var/www;
location / {
index index.html;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# HTTPSの使用例
# server {
# listen 80;
# server_name default_server;
# 80番ポートに来たアクセスを443番ポートにリダイレクト
# return 301 https://$host$request_uri;
# }
# server {
# listen 443;
# ssl on;
# server_name default_server;
# root /var/www;
# location / {
# index index.html
# }
# error_page 404 /404.html;
# location = /40x.html {
# }
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
@190ikp
Copy link
Author

190ikp commented Dec 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment