§2024-07-08

  1. Redirect https://munetaka.me:45103 to hc4Bookworm.yushei.net:48501

Follow the example https://munetaka.me:45101 to hc4noble.yushei.net:45101

# cd /etc/nginx/
root@pi3Nginx:/etc/nginx# ls sites-available/
default  upstream-43410  upstream-43413  upstream-43889  upstream-443  upstream-45101  upstream-8088
root@pi3Nginx:/etc/nginx# pwd
/etc/nginx
root@pi3Nginx:/etc/nginx# cat sites-available/upstream-45101 
# port 453105, hc4noble.yushei.net:45101 nextCloud

server {
     server_name  munetaka.me:45101;
     charset utf-8;

     location / {
        proxy_pass http://hc4noble.yushei.net:45101;
        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 https;
        proxy_set_header X-Forwarded-Host munetaka.me;
        proxy_set_header X-Forwarded-Port 45101;

     }

     listen 45101 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
}
  1. edit sites-available/upstream-45103 as
# port 453103, to hc4bookworm.yushei.net:48501 nextCloud

server {
     server_name  munetaka.me:45103;
     charset utf-8;

     location / {
        proxy_pass http://hc4Bookworm.yushei.net:48501;
        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 https;
        proxy_set_header X-Forwarded-Host munetaka.me;
        proxy_set_header X-Forwarded-Port 45101;

     }

     listen 45101 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
}
  1. link it
root@pi3Nginx:/etc/nginx/sites-enabled# pwd
/etc/nginx/sites-enabled
root@pi3Nginx:/etc/nginx/sites-enabled# ls -l
total 0
lrwxrwxrwx 1 root root 41 Jun  7 11:19 upstream-43410 -> /etc/nginx/sites-available/upstream-43410
lrwxrwxrwx 1 root root 41 Jun  7 14:18 upstream-43413 -> /etc/nginx/sites-available/upstream-43413
lrwxrwxrwx 1 root root 41 Jun  7 12:47 upstream-43889 -> /etc/nginx/sites-available/upstream-43889
lrwxrwxrwx 1 root root 39 Jun  7 09:25 upstream-443 -> /etc/nginx/sites-available/upstream-443
lrwxrwxrwx 1 root root 41 Jun  7 13:24 upstream-45101 -> /etc/nginx/sites-available/upstream-45101
lrwxrwxrwx 1 root root 40 Jun  4 19:41 upstream-8088 -> /etc/nginx/sites-available/upstream-8088
root@pi3Nginx:/etc/nginx/sites-enabled# ln -sf /etc/nginx/sites-available/upstream-45103 upstream-45103
root@pi3Nginx:/etc/nginx/sites-enabled# ls -l
total 0
lrwxrwxrwx 1 root root 41 Jun  7 11:19 upstream-43410 -> /etc/nginx/sites-available/upstream-43410
lrwxrwxrwx 1 root root 41 Jun  7 14:18 upstream-43413 -> /etc/nginx/sites-available/upstream-43413
lrwxrwxrwx 1 root root 41 Jun  7 12:47 upstream-43889 -> /etc/nginx/sites-available/upstream-43889
lrwxrwxrwx 1 root root 39 Jun  7 09:25 upstream-443 -> /etc/nginx/sites-available/upstream-443
lrwxrwxrwx 1 root root 41 Jun  7 13:24 upstream-45101 -> /etc/nginx/sites-available/upstream-45101
lrwxrwxrwx 1 root root 41 Jul  8 14:44 upstream-45103 -> /etc/nginx/sites-available/upstream-45103
lrwxrwxrwx 1 root root 40 Jun  4 19:41 upstream-8088 -> /etc/nginx/sites-available/upstream-8088
  1. restart nginx
# systemctl restart nginx
root@pi3Nginx:/etc/nginx/sites-enabled# systemctl status  nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running) since Mon 2024-07-08 14:44:57 CST; 6s ago
       Docs: man:nginx(8)
    Process: 21552 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 21556 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 21557 (nginx)
      Tasks: 5 (limit: 710)
     Memory: 4.5M (peak: 5.1M)
        CPU: 383ms
     CGroup: /system.slice/nginx.service
             ├─21557 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             ├─21558 "nginx: worker process"
             ├─21559 "nginx: worker process"
             ├─21560 "nginx: worker process"
             └─21561 "nginx: worker process"

Jul 08 14:44:56 pi3Nginx.munetaka.me systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server...
Jul 08 14:44:57 pi3Nginx.munetaka.me systemd[1]: Started nginx.service - A high performance web server and a reverse proxy server.
  1. test https://munetaka.me:45103