Home >Backend Development >PHP Tutorial >Nginx reverse proxy Odoo and convert to https

Nginx reverse proxy Odoo and convert to https

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-28 08:25:531949browse

Generate certificate file

Generate a self-signed certificate and place it in the specified location

<code>$ openssl req -x509 -days <span>3650</span> -subj <span>'/CN=odoo.youyun.com/'</span> -nodes -newkey rsa:<span>2048</span> -keyout server.key -out server.crt
$ <span>sudo</span> mkdir /etc/ssl/nginx
$ <span>sudo</span> mv server.key server.crt /etc/ssl/nginx</code>

Configure nginx

<code>$ <span>sudo</span> rm /etc/nginx/sites-avaliable/default
$ <span>sudo</span> vim /etc/nginx/sites-avalibale/odoo.conf</code>

Delete the default nginx default file and create a new odoo.conf file with the following content

<code><span>server</span> {
    <span>listen</span><span>443</span> default;
    <span>server_name</span> _;

    <span>access_log</span> /var/log/nginx/odoo.access.log;
    <span>error_log</span>  /var/log/nginx/odoo.<span>error</span>.log;

    <span>ssl</span><span>on</span>;
    <span>ssl_certificate</span>     /etc/ssl/nginx/server.crt; <span># 之前生成的证书和key</span><span>ssl_certificate_key</span> /etc/ssl/nginx/server.key;
    <span>ssl_ciphers</span>             HIGH:!ADH:!MD5;
    <span>ssl_protocols</span>           SSLv3 TLSv1;
    <span>ssl_prefer_server_ciphers</span><span>on</span>;

    <span>location</span> / {
        <span>proxy_pass</span><span>http://127.0.0.1:8069</span>;
        <span>proxy_next_upstream</span><span>error</span> timeout invalid_header http_500 http_502 http_503 http_504;

        <span>proxy_buffer_size</span><span>128k</span>;
        <span>proxy_buffers</span><span>16</span><span>64k</span>;
        <span>proxy_redirect</span><span>off</span>;

        <span>proxy_set_header</span> Host <span>$host</span>;
        <span>proxy_set_header</span> X-Real-IP <span>$remote_addr</span>;
        <span>proxy_set_header</span> X-Forwarded-For <span>$proxy_add_x_forwarded_for</span>;
        <span>proxy_set_header</span> X-Forwarded-Proto https;
    }

   <span>location</span><span>~* /web/static/</span> {
        <span>proxy_cache_valid</span><span>200</span><span>60m</span>;
        <span>proxy_buffering</span><span>on</span>;
        <span>expires</span><span>864000</span>;
        <span>proxy_pass</span><span>http://127.0.0.1:8069</span>;
    }
}

<span>server</span> {   <span># 将80端口转到443的https中</span><span>listen</span><span>80</span>;
    <span>server_name</span> __;

    <span>add_header</span> Strict-Transport-Security max-age=<span>2592000</span>;
    <span>rewrite</span><span> ^/.*$</span><span>https://$host$request_uri?</span><span>permanent</span>;
}

<span>server</span> {   <span># 将特定ip的8069端口转到443的https中</span><span>listen</span><span>192.168.1.102:8069</span>; <span># 这是虚机的ip</span><span>server_name</span> __;

    <span>add_header</span> Strict-Transport-Security max-age=<span>2592000</span>;
    <span>rewrite</span><span> ^/.*$</span><span>https://$host$request_uri?</span><span>permanent</span>;
}</code>

Configure the access source host

  • Install the server.crt certificate generated before
  • Modify the hosts file and add it, because the previous certificate used this domain name
    <br> 192.168.1.102 odoo.youyun.com <br>
     Nginx反向代理Odoo并转为https
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces Nginx reverse proxy Odoo and converts it to https, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn