nginx

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > nginx > nginx配置cloudflare

腾讯云服务器记录nginx配置cloudflare证书的实现步骤

作者:佩奇的技术笔记

本文主要介绍了腾讯云服务器记录nginx配置cloudflare证书的实现步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

最近 99 元买了一台腾讯云新加坡的服务器,想着搞个网站放在在上面,但是在 cloudflare 配置了二级域名解析之后不生效,经过排查是因为没配置证书的原因。故而有下面这篇笔记。

希望能帮到你。

1、服务器:腾讯云新加坡轻量云服务器

2、需要配置以.conf结尾的nginx配置文件

server { 
listen 443 ssl; 
server_name xxx.xyz; 
ssl_certificate /etc/nginx/ssl/chat.wisdomflow.xyz-ssl/xxx.com.pem; ssl_certificate_key /etc/nginx/ssl/chat.wisdomflow.xyz-ssl/xxx.com.key; location / { 
    proxy_pass http://172.17.0.1:3000;

    # Add WebSocket support (Necessary for version 0.5.0 and up)

    proxy_http_version 1.1;

    proxy_set_header Upgrade $http_upgrade;

    proxy_set_header Connection "upgrade";

    proxy_set_header Host $host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_set_header X-Forwarded-Proto $scheme;

    # (Optional) Disable proxy buffering for better streaming response from models

    proxy_buffering off;

}

4、配置 docker-compose.yaml 文件

services: 
    nginx: 
        image: nginx:alpine 
        ports: 
            - "80:80" 
            - "443:443" 
        volumes: 
            - ./config/conf.d:/etc/nginx/conf.d  
            - ./ssl:/etc/nginx/ssl

5、把在 cloudflare 生成的证书和私钥配置下见上面的 conf 文件

注意点:要把 nginx 的 ssl 语法写对;docker 访问宿主机的 ip 是172.17.0.1;nginx 的配置文件以.conf结尾。

到此这篇关于腾讯云服务器记录nginx配置cloudflare证书的实现步骤的文章就介绍到这了,更多相关nginx配置cloudflare内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文