Odoo服务器配置nginx主要分为两种,即有无SSL证书的情况,这里主要讲述无SSL证书的反向代理配置
云服务器安全组打开80端口,或使用防火墙打开80端口
1)安装nginx(centOS环境为例)
yum -y install nginx
如安装失败,yum 源中无nginx,添加一下yum源:sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2)备份一下配置文件
cd /etc/nginx
cp nginx.conf nginx.conf.back
3)编辑配置文件,添加Odoo服务端口
vim nginx.conf
找到http{}里面server{},添加或改成一下内容
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name odoo12;
root /opt/odoo/odoo12; #这里注意Odoo项目路径和文件名
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
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_pass http://127.0.0.1:8069;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
然后保存退出
4)检查nginx服务并重启
sudo nginx –t
sudo systemctl restart nginx
sudo systemctl enable nginx
输入服务器IP域名(不用输入端口8069)测试