[Tutorial]How to add 2nd IP for websites

2nd IP is great idea! Thank you so much for your guide!

it’s really nice, thank you for sharing with us

Is there the possibility of pointing to another server (which is on the same network), using a subdomain, in CyberPanel?
Ex: I have a Cyber ​​server on IP 192.168.10.50 and I want the CybePanel to point to the other server using the srvcloud.mydominio.com subdomain, in 192.168.10.51

I have followed the tutorial step by step and everything seems correct.
When I visit the IP, I get a 404 page, in Cyberpanel new site show main ip,… not new ip.
I suppose that need change some file and add new ip to assign this to new site, but where?
Am I missing something?

I get this with ip a

[almalinux@vps-xxxxxxxxx ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether fa:16:3e:fd:38:10 brd ff:ff:ff:ff:ff:ff
inet xxx.xx.xx.xxx/32 scope global noprefixroute eth0 (aditional ip)
valid_lft forever preferred_lft forever
inet xx.xx.xxx.xxx/32 scope global dynamic noprefixroute eth0 (main ip)
valid_lft 66203sec preferred_lft 66203sec
inet6 2001:41d0:304:200::869/56 scope global noprefixroute
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fefd:2910/64 scope link noprefixroute
valid_lft forever preferred_lft forever

Some help?
Thanks.

A Website can have multiple IP addresses when you hosted it at multiple locations. Why? It can be for load balancing or redundancy… Or to serve web pages based on the user location etc… If you are using Linux, you can use tools like dig to get DNS information for a specific website.

thank you for sharing with us..

A server can have multiple ips that you can use for different sites.
yes it is for following thing you mentioned

Hello gasonline, have you managed to progress on this issue?

I too have the exact same issue and looking for assistance.

Edward

No EdwardC,

No, I got no help so my solution was to switch to CWP.
If later on the Cyberpanel team implements this in the panel to make it easy to do I might come back.

Having no luck. Get “ip is already in use”.

Makes me sad that I might have to go back to CWP. CyberPanel is SO MUCH better, but not being able to easily add / assign/ use extra IP’s is crazy.

This is the hard way especially if you are juggling between dozens of websites. You can either script this or copy and paste the IPv4 configs to the IPv6 configs for the new IPv6 listeners in httpd_config.conf, like so. Note the pattern in the map sections.

listener Default {
  address                 *:80
  secure                  0
  map                     websitea.com websitea.com
  map                     subdomaina.websitea.com  subdomaina.websitea.com
}

listener Default IPv6 {
  address                 [ANY]:80
  secure                  0
  map                     websitea.com websitea.com
  map                     subdomaina.websitea.com  subdomaina.websitea.com
}

listener SSL {
  address                 *:443
  secure                  1
  keyFile                 /etc/letsencrypt/live/hostdomain.com/privkey.pem
  certFile                /etc/letsencrypt/live/hostdomain.com/fullchain.pem
  certChain               1
  sslProtocol             24
  enableECDHE             1
  renegProtection         1
  sslSessionCache         1
  enableSpdy              15
  enableStapling          1
  ocspRespMaxAge          86400
  map                     websitea.com websitea.com
  map                     subdomaina.websitea.com  subdomaina.websitea.com
}

listener SSL IPv6 {
  address                 [ANY]:443
  secure                  1
  keyFile                 /etc/letsencrypt/live/websitea.com/privkey.pem
  certFile                /etc/letsencrypt/live/websitea.com/fullchain.pem
  certChain               1
  sslProtocol             24
  enableECDHE             1
  renegProtection         1
  sslSessionCache         1
  enableSpdy              15
  enableStapling          1
  ocspRespMaxAge          86400
  map                     websitea.com websitea.com
  map                     subdomaina.websitea.com  subdomaina.websitea.com
}

Ideally, CyberPanel would be updating all of this in the background. It would be running the same bit of parsing code as it already does when creating a new website and adding a new domain, except it would be adding the domain mappings to the two IPv6 listeners as well. @usmannasir, could you update the website script to add IPv6 listeners to simultaneously update them along with the IPv4 listeners? I am pushing a commit for your approval.

Don’t use CWP. It’s a steaming pile of manure. See my post here:

1 Like

Thank you very much for the information! I will get my tiny brain in gear and input the data:)

Seriously, thank you for taking the time to help.

I put up with CWP for few years because of an IT person in charge and NEVER want to return to it. Wasted a lot of hours on it. Just the thought of loading it onto a server makes my stomach upset.

Retired and on my own now and can choose what panel I want. Really like Cyberpanel but lack of support is bothersome. Thank goodness for people like yourself!

1 Like

When I tried to fill in as in the tutorial, the error message appears that both ports are in use (port 80 and 443)

i try this method getting for cyberpanel openlitespeed but getting error port already in used

@lordmacio @uzairjhandeer use a different port like 81 etc

[Tutorial]How to add 2nd IP for websites under Ubuntu 20 or 22
Under Ubuntu 22 (and perhaps since Ubuntu 18) there is an new method to have your additional IP addresses accounted for.
We will use the new Netplan function of Linux.
1°) First Change the CHMOD to 0600 of the file /etc/netplan/00-installer-config.yaml (the name of this yaml could be different in your case)
2°) Second change your file to have this 3 lines (you will see the complet file above)
addresses:
- XX.XX.XXX.XX/24
- XX.XX.XXX.XX/32

XX.XX.XXX.XX/24 is your first IP (of your server) /24 is the code of the type of your IP (often your main IP has /24 code)
XX.XX.XXX.XX/32 is your additional IP /32 is the code of the type of your IP (often your second IP has /32 code . Ask to your provider if you have a doubt)
(you can add other lines for other additionnals IP)

Don’t use tabulation to indent your code. You must use only space for the indentation of the yaml code

3°) Third (after having saved you yaml file) You have to use SSL command:
sudo netplan apply
you can ignore this warning (WARNING:root:Cannot call Open vSwitch: ovsdb-server.service is not running.)

Now you can test that your new IP is taken into account with this SSL command:
sudo ip a

Here is the code of the complete YAML (XXX have to changed with your data)

# This is the network config written by 'subiquity'
network:
  ethernets:
    eno1:
      addresses:
      - XX.XX.XXX.XX/24
      - XX.XX.XXX.XX/32
      critical: true
      dhcp-identifier: mac
      dhcp4: true
      nameservers:
        addresses:
        - XX.XX.XXX.XX
        - XX.XX.XXX.XX
        search:
        - XXX.net
  version: 2

@usmannasir, there is a bug with CyberPanel’s IPv6 feature that was rolled out. It adds new domains to the SSL IPv6 listener but it neglects to do so for the non-SSL IPv6 listener. I have been having to add these manually. Please fix this!