Score:0

Configure 2 Nginx reverseproxy with SSL

ec flag

I'm tryng do do something with 2 nginx.

I have a wordpress : mywebsite.com

I need this infra :

Infra

I have some difficulties to configure ssl with let'sencrypt.

  • Nginx1 : 198.198.198.2
  • Nginx2 : 241.236.210.2

If I have servername : mywebsite.com in Nginx1 and same servername in Nginx2, I can't generate SSL certificate for Nginx2 because IP was not correct.

Someone can help me to make a secure installation?


Conf DNS:

reverse1ext.domain.com. 0   A   0.0.0.0
reverse1int.domain.com. 0   A   0.0.0.0
site.domain.fr. 0   CNAME   reverse1ext.domain.com.
site.reverse1int.domain.com  0  CNAME  reverse1int.domain.com.

NGINX 1:

upstream upstream1 {
    server site.reverse1int.domain.com:443;
}

server {
    server_name site.domain.com;

    location / {
        proxy_pass https://upstream1;
        proxy_set_header    Host $host;

        proxy_connect_timeout 30;
        proxy_send_timeout 30;
    }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/site.domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/site.domain.com/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 = site.domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    server_name site.domain.com;
    listen 80;
    return 404; # managed by Certbot


}

Nginx2 :

upstream upstream1 {
    server 10.12.12.24;
}

server {

    server_name site.domain.com;

    location / {
        proxy_pass https://upstream1;
        proxy_set_header    Host $host;

        proxy_connect_timeout 30;
        proxy_send_timeout 30;
    }




    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/site.domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/site.domain.com/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 = site.domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot




    server_name site.domain.com;
    listen 80;
    return 404; # managed by Certbot


}

This configuration work but I'm not sure it was very secure and clean

in flag
Please provide your configuration and exactly what you have problems with.
in flag
If that configuration works, what exactly is your problem?
FullFullTwist avatar
ec flag
I'm not en expert with Nginx. I try to found the best and secure way to do what I want. I'm here to discuss about that with other user and try to understand her point of view.
in flag
This site is not made for discussions. It's a question&answer system, if you have problem you state it clearly and others can try to find a solution for it. But without a clear problem description this is not possible. If you want a discussion, you need to ask somewhere else.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.