odoo14配置阿里云免费SSL证书

本文介绍了如何在阿里云上购买并安装免费SSL证书,为两个域名(www.xxx.com.cn和tb.xxx.com.cn)配置Nginx,实现HTTP到HTTPS的完全转换,包括证书上传、Nginx配置详解和长连接处理。
摘要由CSDN通过智能技术生成

在这里插入图片描述
登入阿里云SSL证书管理,点击购买免费版证书配置好域名后下载nginx证书
在这里插入图片描述
有了证书之后,第一步上传证书到服务器,配置nginx,我这配置了两个域名对应odoo两个新建的网站域名

vi /etc/nginx/conf.d/域名.conf
#odoo server
upstream odoo {
 server 127.0.0.1:8069;
}
upstream odoochat {
 server 127.0.0.1:8072;
}

# http -> https
server {
   listen 80;
   server_name www.xxx.com.cn xxx.com.cn;
   #将所有HTTP请求通过rewrite指令重定向到HTTPS。
   rewrite ^(.*) https://$host$1 permanent;
}
server {
    listen 443 ssl;
	server_name www.xxx.com.cn xxx.com.cn;
	#配置www域名让xxx.com.cn域名也重定向跳转到www.xxx.com.cn
	if ($host != 'www.xxx.com.cn') {
	  rewrite ^/(.*)$ https://www.xxx.com.cn/$1 permanent;
    }
	root html;
	index index.html index.htm;
	ssl_certificate cert/5032395_www.xxx.com.cn.pem;  #需要将cert-file-name.pem替换成已上传的证书文件的名称。
	ssl_certificate_key cert/5032395_www.xxx.com.cn.key; #需要将cert-file-name.key替换成已上传的证书密钥文件的名称。
	ssl_session_timeout 5m;
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_prefer_server_ciphers on;
	proxy_read_timeout 720s;
	proxy_connect_timeout 720s;
	proxy_send_timeout 720s;

    # Add Headers for odoo proxy mode
	proxy_set_header X-Forwarded-Host $host;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto $scheme;
	proxy_set_header X-Real-IP $remote_addr;

	# log
	access_log /var/log/nginx/odoo.access.log;
	error_log /var/log/nginx/odoo.error.log;

	# Redirect longpoll requests to odoo longpolling port
	location /longpolling {
	proxy_pass http://odoochat;
	}

	# Redirect requests to odoo backend server
	location / {
	proxy_redirect off;
	client_max_body_size    64m; #表示最大上传10M,需要多大设置多大。
	proxy_pass http://odoo;
	}

	# common gzip
	gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
	gzip on;
}


# http -> https
server {
   listen 80;
   server_name tb.xxx.com.cn;
   #将所有HTTP请求通过rewrite指令重定向到HTTPS。
   rewrite ^(.*) https://$host$1 permanent;
}
server {
    listen 443 ssl;
	server_name tb.xxx.com.cn;
	root html;
	index index.html index.htm;
	ssl_certificate cert/5033308_tb.xxx.com.cn.pem;  #需要将cert-file-name.pem替换成已上传的证书文件的名称。
	ssl_certificate_key cert/5033308_tb.xxx.com.cn.key; #需要将cert-file-name.key替换成已上传的证书密钥文件的名称。
	ssl_session_timeout 5m;
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_prefer_server_ciphers on;
	proxy_read_timeout 720s;
	proxy_connect_timeout 720s;
	proxy_send_timeout 720s;

    # Add Headers for odoo proxy mode
	proxy_set_header X-Forwarded-Host $host;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto $scheme;
	proxy_set_header X-Real-IP $remote_addr;

	# log
	access_log /var/log/nginx/odoo.access.log;
	error_log /var/log/nginx/odoo.error.log;

	# Redirect longpoll requests to odoo longpolling port
	location /longpolling {
	proxy_pass http://odoochat;
	}

	# Redirect requests to odoo backend server
	location / {
	proxy_redirect off;
	client_max_body_size    64m; #表示最大上传10M,需要多大设置多大。
	proxy_pass http://odoo;
	}

	# common gzip
	gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
	gzip on;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值