[Solved] Odoo with Let's Encrypt and Nginx reverse proxy


#1

Hi, I created a site using:

ee site create mysite.example.com --proxy=127.0.0.1:8069

Now I am trying to setup Let’s Encrypt, what is the best way to do it? I am having issues trying to get a validation for my domain.

Thanks in advance.


#2

I have the same issue with a docker container, and I have setup an html website to setup the SSL certificate, then I have used it for the proxy. That’s not the “best practice” but it work


#3

Thanks for your response! Can you share your Nginx config? I did as you said, and the SSL certificate works, but after the login process the CSS files returned 404, so I added the location ~* /web/static/ block (I found that at https://www.odoo.com/forum/help-1/question/nginx-reverse-proxy-on-80-443-32052), but now I am getting these errors in the Chrome console:

GET https://mysite.example.com/web/content/245-dc05de8/web.assets_common.0.css
web:23 GET https://mysite.example.com/web/content/258-473815e/web.assets_backend.0.css
web:24 GET https://mysite.example.com/web/content/259-473815e/web.assets_backend.1.css
web:13 GET https://mysite.example.com/web/content/246-dc05de8/web.assets_common.js
web:15 Uncaught ReferenceError: odoo is not defined(anonymous function) @ web:15
web:25 GET https://mysite.example.com/web/content/260-473815e/web.assets_backend.js
web:23 GET https://mysite.example.com/web/content/258-473815e/web.assets_backend.0.css
web:24 GET https://mysite.example.com/web/content/259-473815e/web.assets_backend.1.css
web:28 Uncaught ReferenceError: $ is not defined

Relevant Nginx config:

add_header X-Proxy-Cache $upstream_cache_status;
location / {
    proxy_pass http://127.0.0.1:8069;
    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

proxy_redirect      off;
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 https;
}

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

#4

You have to create again the ssl.conf file and also the force-ssl.conf (optional)

Like describe in the manual setup : https://easyengine.io/tutorials/nginx/letsencrypt/


#5

Yes, I already have that configuration. My problem are the static files not being found.


#6

I have just use :

ee site create yourdomain.com --letsencrypt 
ee site delete yourdomain.com
ee site create yourdomain.com --proxy=Your-ip-address

And I have only include the ssl.conf file after I don’t remember exactly if I have change something after, I don’t use it anymore


#7

Finally I solved my issue, I had to add ~* to the block:

location ~* / {
        proxy_pass http://127.0.0.1:8069;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

    proxy_redirect      off;
    proxy_buffering off;
    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 https;
}

Let's Encrypt with subdomain not working?
#8