I configure the web server, in the configs you need to specify:

  • for apache2: /etc/apache2/conf.d "VirtualHost your-ip : 81"

  • for nginx: /etc/nginx/nginx.conf "upstream B {server your-ip : 81;}"

  • neither one nor the other. you need to specify the ip that is assigned to the network interface of the machine. see the output of $ ip a - aleksandr barakin

1 answer 1

in fact, two questions are completely unrelated to each other . This is not accepted on stackoverflow, but I will give an answer to the second question.

apache virtualhost

In general, there you can specify an ip-address (or a domain name, which is resolvable to it), available to local processes for listening. you can see the available addresses, for example, using the ip a command. example:

 $ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 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 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:11:00:09 brd ff:ff:ff:ff:ff:ff inet 172.17.0.9/16 scope global eth0 valid_lft forever preferred_lft forever 

it shows that the connection with the "outside world" for this machine is available through one ip-address - 172.17.0.9 . in such a situation, you can not specify this unique address, but get by with the instruction “listen to all available ip-addresses”:

 <virtualhost *:81> 

For more information on the virtualhost directive , see the documentation .

nginx upstream server

in the nginx program, the upstream directive describes a group of servers . inside the upstream block, servers can be specified with the server directive , in which the address can be specified as a domain name or ip-address, and an optional port, or as a unix-socket path.

if you specify an ip-address, it should be the address to which this server is accessible from the machine where the nginx program is running, which you are configuring.


addition

if both programs about which the question is about - apache and nginx - run on the same machine, then in both configuration files you can specify the loopback -address - localhost or 127.0.0.1 . this will be more than enough for communication between these programs in this situation.

  • Thanks for the detailed explanation! - kirill fedorov