nginx启动ssl端口的示例:
1.打开nginx配置文件,例如:“/etc/nginx.conf”。
2.在文件里的“http{}”声明内添加以下代码:
server {
listen 443 ssl http2; //监听的端口
server_name 172.16.3.64; //可用的IP地址
root /var/www/html/;
index index.php index.html index.htm;
#charset koi8-r;
access_log /var/log/nginx/access_log;
error_log /var/log/nginx/error_log error;
# SSL/TLS configs
ssl on;
ssl_certificate server.pem;
ssl_certificate_key privkey.pem;
location / {
proxy_pass http://127.0.0.1:8111;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
3.启动nginx,打开项目查看效果。
//启动nginx命令
service nginx start