Answer the question
In order to leave comments, you need to log in
How to run sites under Apache and Nginx on the same ip?
Hello.
There is one static ip and several machines.
Machine 192.168.1.2 under Apache behind a router on which port 80 is open. And there is a machine in the same network 192.168.1.4 under Nginx and port 8080 is open on it.
Sites that are available on machine 192.168.1.2 as site.ru, site2.ru
Sites that are available on machine 192.168.1.4 as mysite.ru:8080, mysite2.ru8080
How to make sites on machine 192.168.1.4 available mysite.ru, mysite2.com???
What needs to be done in this case, to configure it like Apache or nginx, or is it not possible to do this at all within the aisles of one static ip?
The provider said he does not have the ability to issue several static ip addresses per account.
Answer the question
In order to leave comments, you need to log in
https://docs.nginx.com/nginx/admin-guide/web-serve... or https://httpd.apache.org/docs/2.4/howto/reverse_pr...
Proxy traffic to apache through nginx if you need apache. Or do not proxy - if you need nginx. As a result, the input is always nginx - this is now generally a standard solution.
nginx as reverse proxy. Forwarding ports 80 and 443 from the gate to the reverse proxy. That, in turn, should proxy requests from you depending on the url that the client calls.
Thank you all for your help. Made by myself with tips from user DevMan.
Since I have Openserver under Windows, there is not much different structure there.
You need to create a new site directory in the domains directory, for example mysite. Copy the file of the version of Apache used into it, for me it is Apache-2.4_vhost.conf. I have this file on this path D:\openserver\userdata\config\Apache-2.4_vhost.conf (you have your own path to the openserver).
Further, in the settings of the open server in domains, I added this directory mysite.ru to the list of created domains.
Further, in the Apache-2.4_vhost.conf file, I added a redirect to the machine I need in the host that is there by default.
<VirtualHost *:%httpport%>
DocumentRoot "%hostdir%"
ServerName "%host%"
ServerAlias "%host%" %aliases%
ScriptAlias /cgi-bin/ "%hostdir%/cgi-bin/"
ProxyRequests Off
ProxyPass "/" "http://192.168.1.4:8080/"
ProxyPassReverse "/" "http://192.168.1.4:8080/"
</VirtualHost>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question