Skip to content

openresty https设置

Configuring HTTPS servers

示例的详细设置请参考 链接

运行示例步骤:

  • 生成https证书

    bash
    docker run --rm -it -v $(pwd):/opt/temp nginx sh -c 'cd /opt/temp && openssl req -out cert.csr -new -nodes -newkey rsa:2048 -keyout key.pem'
    
    docker run --rm -it -v $(pwd):/opt/temp nginx sh -c 'cd /opt/temp && openssl x509 -req -days 36500 -in cert.csr -signkey key.pem -out cert.crt && rm cert.csr'
  • 运行openresty

    bash
    docker-compose up
  • 访问示例https://localhost

示例https的核心配置如下:

nginx
listen       82 ssl;
server_name  localhost;

ssl_certificate cert.crt;
ssl_certificate_key key.pem;