I'm pretty new to nginx and I'm trying to configure a redirect from http to https and, in the same file, set as location a proxy_pass to the desired URL.
My domain.com file is this:
server {
listen 80;
server_name my.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name my.example.com;
ssl on;
ssl_certificate /etc/nginx/certificate/example.com/certificate.crt;
ssl_certificate_key /etc/nginx/certificate/example.com/privkey.key;
location / {
proxy_pass https://other.example.org:10302/some/folder/;
proxy_buffering off;
include proxy_params;
}
}
if I run nginx -t I got sintax OK, if I reload nginx it reload w/out issues but if I point to my.domain.com I see default nginx page (in http), no redirect to https, non proxy_pass; if I point to https://my.example.com I got connection refused, if I point to https://other.example.org:10302/some/folder/ I can connect w/out any issue.
My certificate.crt is made with:
openssl x509 -in certificate.csr -out certificate.crt
is it ok or I need to made it in a different way?
Anyone could point me in the right direction? Thanks in advance, Alessandro