Nginx †
概要 †Nginxは静的コンテンツの高速配信ができるサーバ。 dockerコンテナとして起動する(お試し) †docker pull nginx:latest sudo docker run -d -p 8080:80 nginx あとは docker exec -it でコンテナに入ってファイル作成等を行う。
dockerイメージを作る †配信するコンテンツの作成 †www/index.html <!doctype html> <html lang="ja"> <head> <meta charset="utf-8"> </head> <body> Test Nginx! </body> </html> Dockerfileの作成 †Dockerfile FROM nginx RUN mkdir -p /var/www COPY www /var/www COPY default.conf /etc/nginx/conf.d/default.conf CMD nginx -g "daemon off;" コンテナのビルド †docker build ./ -t nginx-sample1 コンテナの起動 †docker run -d -p 8080:80 nginx-sample1 CentOS へのインストール †http://nginx.org/en/linux_packages.html#stable yum リポジトリの追加 †/etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1 インストール †yum install -y nginx 起動 †# 自動起動をON sudo systemctl enable nginx # 起動 sudo systemctl start nginx 設定ファイルについて †メインの設定ファイルである /etc/nginx/nginx.conf では /etc/nginx/conf.d 配下にあるバーチャルホスト毎の設定ファイルを読み込むように記述されている。 /etc/nginx/nginx.conf .
.
http {
.
.
include /etc/nginx/conf.d/*.conf;
}
インストール直後の /etc/nginx/conf.d 配下には、default.conf というデフォルトの設定ファイルのみが存在する。 /etc/nginx/conf.d/default.conf server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
SSLサーバ証明書の設定 †TODO:
|