Welcome! Log In Create A New Profile

Advanced

Is this configuration correct?

Posted by gusto1 
Is this configuration correct?
January 08, 2022 03:56AM
I use Nginx as a reverse proxy server.

web_server_apache ----> Nginx_reverse_proxy ----> Internet

Today I have successfully generated certificates from let's encrypt for my private subdomains. Everything works great. I have two private subdomains (site1 and site2). I placed both subdomains in one config file. Is this configuration correct?

<code>
# -----------site1-subdomain------------#
server {
server_name site1.example.com;

location / {
proxy_pass http://192.168.1.110;
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 $scheme;
}

listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com-0001/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com-0001/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

}

server {
if ($host = site1.example.com) {
return 301 https://$host$request_uri;
}


listen 80;
server_name site1.example.com;
return 404;


}

# -----------site2-subdomain------------#
server {
server_name site2.example.com;

location / {
proxy_pass http://192.168.1.110;
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 $scheme;
}

listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com-0001/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com-0001/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

}

server {
if ($host = site2.example.com) {
return 301 https://$host$request_uri;
}


listen 80;
server_name site2.example.com;
return 404;


}
</code>
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 84
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready