New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
How to assign different ipv6 for each domain?
I have a KVM VPS running Ubuntu 22.04 and using nginx as the webserver. I have a IPv6 /64 block so I added the extra IPs in the control panel. I want to assign a different ip for each domain so I uploaded a php file to find out what ipv6 my server shows to public but it's displaying the wrong ip address it's using whatever the last ipv6 created. This is my nginx config:
server {
listen [79de:d3e4:211c:3963:e2d5:4b9d:00b8:2c60]:80;
server_name sub.domain.com www.sub.domain.com;
root /var/www/sub.domain.com/htdocs;
index index.php index.html index.htm;
}
php:
// create a new cURL resource
$ch = curl_init ();
// set URL and other appropriate options
curl_setopt ($ch, CURLOPT_URL, "http://ipecho.net/plain");
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
// grab URL and pass it to the browser
$ip = curl_exec ($ch);
echo "The public ip for this server is: $ip";
// close cURL resource, and free up system resources
curl_close ($ch);
How can make each IP independent so IP 1 outgoing IP display as IP 1, IP 2 as IP 2, IP 3 as IP 3 etc...
Comments
You are looking at different things..
If you assign a different IP to each domain, whichever IP the traffic comes to, your server will respond from.
Outgoing traffic, could use any IP on the system. This is the same reason that the license checks people do to see if someone is using a "nulled-license" can fail to detect properly licensed servers.
No different than multiple IPv4 addresses on a host.
You have to properly configure dn-server. That's where client get IP for given domain name...
Do you mean by adding AAAA record? if so I've already done that and it will still give wrong outgoing ip
You haven't demonstrated that it is though.
To demonstrate it, WireShark would be the easiest way.. Open the website on the client and see what IP address sends the data.
PHP-FPM can create multiple pools with different running user.
In your Nginx config, assign each domain with individual user, then perform SNAT according to the process owner by using iptables:
1003/1004 is the UID of your PHP-FPM process.
The IP after "--to-source" is your outgoing IP.
Will it increase RAM usage if I attempted to make 100 individual users?
Yes, the idle PHP-FPM processes still occupy some memory. You can set "pm.start_servers" and "pm.min_spare_servers" to 1 to reduce memory usage.
It will definitely increase memory usage because each website will require its own FPM pool. If you are sure you need a separate IP for the OUTGOING connection for each website, and you have 100 websites, Apache (with Nginx in front if needed) with SuPHP can be the better option for using with the mentioned iptables rules.