§2023-04-06

pi2Nginx.munetka.me

  1. sites-enables
[alexlai@pi2NginxMuNeTaka ~]$ ls -l /etc/nginx/sites-enabled/
total 0
lrwxrwxrwx 1 root root 34 Dec 21 09:48 default -> /etc/nginx/sites-avaliable/default
lrwxrwxrwx 1 root root 41 Dec 21 14:25 upstream-43100 -> /etc/nginx/sites-avaliable/upstream-43100
lrwxrwxrwx 1 root root 41 Dec 21 14:39 upstream-43410 -> /etc/nginx/sites-avaliable/upstream-43410
lrwxrwxrwx 1 root root 41 Dec 21 14:34 upstream-47007 -> /etc/nginx/sites-avaliable/upstream-47007
lrwxrwxrwx 1 root root 41 Apr  6 13:30 upstream-48001 -> /etc/nginx/sites-avaliable/upstream-48001
  1. /etc/nginx/sites-avaliable//upstream-47007 as,
# port 47007, MyMarineLogbooks@h2Jammy.yushei.net:47007 
upstream MyMarineLogbooks {
       server h2Jammy.yushei.net:47007 weight=1;
}

server {
     # listen       47007;
      
     server_name  munetaka.me:47007;
     charset utf-8;

     location / {
         proxy_pass http://MyMarineLogbooks;
     }

    # the followings are added byt Let's Envrypted
    listen 47007 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/munetaka.me/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/munetaka.me/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
}

以下: chaptGPT In Nginx, an "upstream server" refers to a group of one or more backend servers that are used to handle client requests.

An upstream server can be defined using the upstream directive in the Nginx configuration file. This directive allows you to specify a group of servers, along with their IP addresses or hostnames, that Nginx should proxy client requests to.

For example, let's say you have two backend servers with IP addresses 192.168.1.10 and 192.168.1.11, both of which are running a web application on port 8080. You could define an upstream server group in Nginx like this:

upstream backend {
    server 192.168.1.10:8080;
    server 192.168.1.11:8080;
}

In this configuration, the upstream directive defines an upstream server group called "backend" that includes the two servers on IP addresses 192.168.1.10 and 192.168.1.11, both running on port 8080.

Once the upstream server group is defined, you can use it in your Nginx location directive to proxy client requests to the backend servers. For example:

location / {
    proxy_pass http://backend;
}

In this example, the proxy_pass directive is used to forward all client requests to the "backend" upstream server group that we defined earlier. Nginx will then load-balance the requests across the two backend servers, distributing the traffic between them based on the weight parameter or other load-balancing methods you have configured.

By using an upstream server group, you can easily scale your application by adding or removing backend servers without changing your Nginx configuration. You can also configure health checks and other advanced features to ensure that the backend servers are responding correctly and that traffic is distributed efficiently.