我是靠谱客的博主 年轻奇迹,最近开发中收集的这篇文章主要介绍nginx作为odoo的反向服务器配置,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

nginx的安装略。

使用web服务器nginx作为odoo的反向代理服务器有以下几个优点:

1.缓存网页的静态内容,加快网页的加载速度。一个很直观的体验就是,如果没有nginx作为反向代理服务器,隔一段时间没访问odoo,发现浏览器要加载好长时间才出现页面,而nginx作为反向代理服务器后打开网页速度明显加快了。

2.利用nginx做数据分发,在分布式部署情况下能突破服务器的性能限制。

3.如果一台服务器有多个web服务(比如同时存在apache、odoo)都需要共用一个80端口,可以利用nginx作为反向代理服务器根据用户访问的域名进行数据分发。

修改nginx.conf的配置文件。

gzip功能优化参考以下链接。

https://blog.csdn.net/zhuyiquan/article/details/52709864

如下

 
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    
    gzip  on;  #开启gzip,加快oe首页的加载速度。                                                                                 #小于1k的文件将不会被压缩,防止文件越小压缩后反而变大                                                                            gzip_min_length 1024;                                                                                                    #为防止乱码,1.1以上的http协议版本的浏览器才会启动gzip功能                                                                       gzip_http_version 1.1;                                                                                                   #设置压缩级别1-9,级别越高对cpu的负载就越大。设置为1就足够了        
    gzip_comp_level 1;                                                                                                       #设置进行压缩的文件类型。JavaScript有很多中形式。其中的值可以在mime.type文件中查找                                                 gzip_types text/plain application/javascript application/x-javascript text/css                                            application/xml text/javascript/x-httpd-php image/jpeg image/gif image/png application/                                 vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml;                                                      #是否在http header中添加Vary accept-encoding,建议开启                                                                       gzip_vary on;                                                                                                            #禁用ie6 gzip                                                                                                             gzip_disable "MSIE [1-6].";                                                                                              #设置压缩所需要的缓冲区大小                                                                                                  gzip_buffers 32 4K;                               
    server {
        listen       80;   #监听80端口
        server_name  59.110.222.158;  #

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass http://59.110.222.158:8069;    #反向代理服务器的ip:端口
            proxy_set_header X-Real-Ip $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
        }                                                                                                                        #开启ngixn_status,zbbix等监控平台可以通过该模块获取nginx状态。前提是nginx需要安装http_stub_status_module模块
        location  /nginx-status {                                                                                                                 stub_status on;                                                                                                          access_log  off;                                                                                                         allow 127.0.0.1; #只允许本地拉取nginx状态数据                                                               }
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ .php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ .php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

效果:


最后

以上就是年轻奇迹为你收集整理的nginx作为odoo的反向服务器配置的全部内容,希望文章能够帮你解决nginx作为odoo的反向服务器配置所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部