- 启用stub_status模块,只能本机120.0.0.1访问,用于elk nginx metric监控
- 默认服务为blog,转发到hexo博客的public目录,强制跳转到https
- 代理二级域名elk.jhzhang.top,免去输入端口的不便
- blog域名启用https
- elk域名启用https
user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
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;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name 127.0.0.1;
include /etc/nginx/default.d/*.conf;
location /nginx_status {
stub_status on;
allow 127.0.0.1;
deny all;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name www.jhzhang.top jhzhang.top;
rewrite ^(.*)$ https://$host$1;
include /etc/nginx/default.d/*.conf;
location / {
root /root/blog/public;
index index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 80;
listen [::]:80;
server_name elk.jhzhang.top;
rewrite ^(.*)$ https://$host$1;
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://127.0.0.1:5601;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 443 ssl;
server_name www.jhzhang.top jhzhang.top;
ssl_certificate /root/sslCert/5719168_www.jhzhang.top.pem;
ssl_certificate_key /root/sslCert/5719168_www.jhzhang.top.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location / {
root /root/blog/public;
index index.html index.htm;
}
}
server {
listen 443 ssl;
server_name elk.jhzhang.top;
ssl_certificate /root/sslCert/8196999_elk.jhzhang.top.pem;
ssl_certificate_key /root/sslCert/8196999_elk.jhzhang.top.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:5601;
}
}
}