それぞれの最低限の設定
とりあえず「Welcome to nginx on the Amazon Linux AMI!」の画面を表示させる設定
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http{
server{
listen 80;
listen [::]:80;
server_name sample.com;
root /usr/share/nginx/html;
location / {
root /var/www/html;
index index.php index.html index.htm;
}
}
}
ただ、プロセスを正常?起動させるためだけなら下記で大丈夫(らしい)
nginx.conf
events{}
「Welcome to nginx on the Amazon Linux AMI!」の画面は表示されません
デフォルトで設定されてる形
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http{
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server{
listen 80;
listen [::]:80;
server_name sample.com;
root /usr/share/nginx/html;
location / {
index index.php index.html index.htm;
}
}
}
※gzipはオンにしたほうが良いだろうか…更新多いコンテンツ提供する場合プロキシ―サーバーやキャッシュサーバーで少々問題が発生するので…
※セキュリティ的なものは下記を参照してください。
セキュリティ的に付け加えたもの
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http{
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
add_header X-Frame-Options SAMEORIGIN;
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options nosniff;
server{
listen 80;
listen [::]:80;
server_name sample.com;
root /usr/share/nginx/html;
location / {
index index.php index.html index.htm;
}
}
}
バージョンを非表示したり、クリックジャッキング対策やクロスサイトスクリプティングの文言を追記してます。
追記したのは下記。
nginx.conf
server_tokens off;
add_header X-Frame-Options SAMEORIGIN;
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options nosniff;