Buenas Gente a ver estoy con el tema de redireccionamiento en https y con www para el dominio va todo bién pero cuando ingreso dominio.com no me lleva a www.dominio.com, os pongo la configuración que tengo en nginx para ver si me podeis echar una mano.
upstream odoo { server 127.0.0.1:8069; } server { server_name dominio.com; access_log /var/log/nginx/odoo.access.log; error_log /var/log/nginx/odoo.error.log; proxy_buffers 16 64k; proxy_buffer_size 128k; location / { proxy_pass http://odoo; 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://odoo; } }
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/dominio.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dominio.com/prvkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}upstream odoo { server 127.0.0.1:8069; } server { server_name www.dominio.com; access_log /var/log/nginx/odoo.access.log; error_log /var/log/nginx/odoo.error.log; proxy_buffers 16 64k; proxy_buffer_size 128k; location / { proxy_pass http://odoo; 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://odoo; } }
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/dominio.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dominio.com/prvkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = dominio.com) {
return 301 https://$host$request_uri;
}
listen 80;
server_name dominio.com;
return 404;
}server {
if ($host = www.dominio.com) {
return 301 https://$host$request_uri;
}
listen 80;
server_name www.dominio.com;
return 404;
}
Esta es la configuración que tengo se que me falta algo pero no doy con lo que es, a ver si me podeis ayudar gente, gracias de antemano.