Xampp + IIS works together on the same server

I have one server with two IP addresses.

I have multiple applications in .net (webapi, console application, etc.), and one of them uses PHP, which runs on apache (w / xampp).

I configured IIS on port 80 by default, and xampp uses port 8080.

As I said, I have two IP addresses and two domains (for example: domain1.com and domain2.com).

I need to point domain1.com.br to an IIS application (which works), but my php application will never be reached, since all requests are routed to port 80 (which iis takes control).

  • What can I do to solve this problem?
  • I know that I can point both ip to port 80, but how to tell IIS whenever it receives a request from a specific domain / host (in this case domain2.com.br), it redirects to port 8080?
+5
source share
2 answers

You may need apache to take control because of apache redirection functions. The main idea is to configure apache, use the apache redirection functions (vhost, if you prefer to call it) to forward special requests to your IIS server.

  • Change IIS by listening on port 8080 (and, for example, set the domain to your domain, for example domain1.com). Run your apache to listen on 80.

  • Include the module below in the apache configuration file (http.conf):

    LoadModule proxy_module modules/mod_proxy.so

    LoadModule proxy_connect_module modules/mod_proxy_connect.so

    LoadModule proxy_http_module modules/mod_proxy_http.so

    LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

And Include:

  Include conf/extra/httpd-vhosts.conf 

3. The next step is to configure the virtual host. Edit the configuration file conf\ extra\httpd-vhosts.conf

 <VirtualHost *:80> DocumentRoot "x:\The\Dir\to\Your\Php\Site" ServerName domain2.com.br ErrorLog "logs/domain2-error.log" CustomLog "logs/domain2-access.log" common </VirtualHost> 

And the installation on your domain2.com.br will be completed. Restart your Apache server, go to your site by domain name, and your php site should work.

  1. If the steps work fine, this will be the last step.

     <VirtualHost *:80> ServerName your.net.site.domain.com ProxyPreserveHost On ProxyPass "/" "http://127.0.0.1:8080/" ProxyPassReverse "/" "http://127.0.0.1:8080/" ErrorLog "logs/domain1-error.log" CustomLog "logs/domain1-access.log" common </VirtualHost> 

And now it should work as you expect.

0
source

Use

Reverse Proxy Method

What is the Reverse Proxy Method

  • A reverse proxy server is a type of proxy server that usually sits behind a firewall on a private network and routes client requests to the corresponding server server. Reverse proxy provides an additional layer of abstraction and control to ensure a smooth flow of network traffic between clients and servers.

Refer to the NGINX Documentation to learn more about reverse proxies.

You can use the reverse proxy server either on the IIS server or Apache (Xampp). But since you have Windows Server, I recommend you do a reverse proxy on the IIS server.

Example: Rewrite or reverse proxy in IIS

0
source

Source: https://habr.com/ru/post/1275007/


All Articles