vpn – How to reverse a proxy https over ip with nginx?

I have a server that connects to another via a VPN, this server will be used as a reverse proxy in our Private networkWhat I want is to allow only https calls to the server of our private network.

How can I restrict secure calls only for our private networks? (for example.

Currently, I have assigned an external IP address to the server. This external IP address is associated with a DNS name (for example, myserver.domain.tld) and I consume the server's web service on the other side of the VPN using this domain. I've added a cert we will encrypt to enable SSL in the domain name.

server {
server_name myserver.domain.tld;
set $ upstream;
access_log /var/log/nginx/reserve-access.log;
error_log /var/log/nginx/reverse-error.log;

location / {
upstream proxy_pass $;
proxy_set_header Host $ host;
proxy_set_header X-Real-IP $ remote_addr;

listen to 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/myserver.domain.tld/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/myserver.domain.tld/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
server {
if ($ host = myserver.domain.tld) ​​{
return 301 https: // $ host $ request_uri;
} # managed by Certbot
server_name myserver.domain.tld;
listen to 80;
return 404; # managed by Certbot