user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /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 Configuration for hqxiaozou.top
server {
#监听443端口
listen 443 ssl;
#你的域名
server_name www.hqxiaozou.top hqxiaozou.top;
#ssl证书的pem文件路径
ssl_certificate /SSL/hqxiaozou.top_bundle.pem;
#ssl证书的key文件路径
ssl_certificate_key /SSL/hqxiaozou.top.key;
location / {
proxy_pass http://你的ip:端口号;
#用户真实ip配置
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 80;
server_name www.hqxiaozou.top hqxiaozou.top;
#将请求转成https
rewrite ^(.*)$ https://$host$1 permanent;
}
# Include the rest of the files in the conf.d directory, if any.
include /etc/nginx/conf.d/*.conf;
}
Nginx线上配置https示例文件
于 2024-06-24 21:52:40 首次发布