Xampp + IIS working together on the same server - apache

I have one server with 2 ip addresses.
I have multiples applications in .net (webapi, a console application, etc) and one specific using PHP which is running on apache (w/ xampp).
I configured IIS to run on default port 80 and xampp is using port 8080.
As I said before, I have two ip addresses and two domains (eg: domain1.com and domain2.com).
I need to pinpoint domain1.com.br to the IIS app (which is working) but my php app never get reached since all the requests are directed to port 80 (which iis takes control).
What can I do to solve this?
I know that I can point both ip's to port 80 but how to tell IIS whenever he gets a request from a specific domain/host (in this case, domain2.com.br) he redirects to the port 8080?

You may need to let the apache takes the control,due to apache's redirect features.The main idea is to setup the apache, use apache's redirect features(vhost,if you prefer to call it so) to direct the special requests to your IIS server.
Change your IIS listening to port 8080 (and set the domain to your domain,domain1.com for example).Leave your apache to listen on 80.
Enable the module below in your apache config 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 Enable:
Include conf/extra/httpd-vhosts.conf
3. The next step is to setup the virtual host. Edit the config fileconf\ 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 setup to your domain2.com.br is Done.Restart your apache server,visit your site by domain name ,and your php site shall be working.
If the steps upon is working as expected,this shall 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 it to.

Use
Reverse Proxy method
What is Reverse Proxy Method
A reverse proxy server is a type of proxy server that typically sits
behind the firewall in a private network and directs client requests
to the appropriate backend server. A reverse proxy provides an
additional level of abstraction and control to ensure the smooth flow
of network traffic between clients and servers.
Refer NGINX Documentation to know more about Reverse Proxy.
You can use reverse proxy either on your IIS or Apache(Xampp) Server. But since you have a Windows Server I recommend you to do reverse proxy on IIS server.
Example: Rewrite or Reverse proxy in IIS

Related

How to setup a IBM HTTP Reverse proxy infront of couple other IBM HTTP Servers that have been configured to a WebSphere cluster

I have couple of IBM HTTP Servers v8.5, IHS1 and IHS2 configured to two managed nodes on a WebSphere cluster that is running DefaultApplication.
I had setup SSL(on default port 443) on these two IHS1 and IHS2 servers and configured plug-in xml to access the applications like snoop. So now, I can access snoop application via the URLs
https://ihs1/snoop and
https://ihs2/snoop
I now want to setup another IBM HTTP server on a another machine, that would have a single URL, say https://loadbalancer , sitting in front of the above two machines, to act as a loadbalancer and distribute the client's requests to the above two URLs. All my application clients must only be able to access the snoop app via https://loadbalancer/snoop
I have started in this direction, through a reverse proxy configuration on this loadbalancer, but no luck.
In httpd.conf, I have uncommented the three lines
LoadModule ibm_ssl_module modules/mod_ibm_ssl.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
and the VirtualHost block looks as below:
Listen 0.0.0.0:443
<VirtualHost loadbalancer:443>
SSLEnable
SSLProtocolDisable SSLv2
SSLClientAuth 0
ProxyPass / https://ihs1/
ProxyPass / https://ihs2/
ProxyPreserveHost on
SSLProxyEngine on
</VirtualHost>
KeyFile C:/IBM/HTTPServer/ihsserverkey.kdb
SSLDisable
Any definitive httpd.conf configuration suggestions on the loadbalancer? or is this path completely different?
This is not really an IBM topology. IHS 7.0 through 8.5.5 contains mod_proxy_balancer (in the WebSphereCE/ subdirectory) that would allow you to load-balance two backends this way with mod_proxy, but it would not be supported by IBM.
If both tiers are really necessary, use something in the very front that is either an IP sprayer (layer 3/4) or a standalone HTTP proxy server.
It is also possible to rig a plugin-cfg.xml statically to use IHS+WAS Plugin at the front tier, but it's not so straightforward.

Using httpd as reverse proxy

This is the first time I have to do something like this. I'm developing a front end application with some stuff I cannot change - it requests some specific address for the serverside data.
I need to redirect all those requests to say:
https://192.168.1.1:8443/server
to a different address, say
https://192.168.100.100:8443/server
I figured this is a job for Reverse Proxy and google brought me to httpd.
Now I work on Windows 7 machine, I've managed to get Apache24 binaries and started it on default 80 port, 127.0.0.1 says "It works!".
I tried to configure a virtual host but no matter what I do, I cannot get it to redirect.
I'm just trying to test the basic stuff first.
I've enabled required mods:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
I've uncommented following include:
Include conf/extra/httpd-vhosts.conf
And inside that file I got this:
<VirtualHost *:80>
ServerName mytest.com
ProxyPass /proxy/ http://myip:tomcatport/myapp/
ProxyPassReverse /proxy/ http://myip:tomcatport/myapp/
</VirtualHost>
I've looked through quite a few of tutorials on how to configure it and tried half a dozen different combinations of the same basic things, configured in this VirtualHost, but no matter what I do, I cannot get it to work.
From what I gathered, this configuration should redirect my browser from mytest.com to http://myip:tomcatport/myapp/, what am I doing wrong here?

Best approach to set up PHP and Java application on same host

I have two web applications one in PHP and one in Java (Play framework).
I want to make both these applications available to my clients and I have only one server for test environment.
What would be the best and easy to maintain approach for my problem?
I am already looking at options of virtual hosts on Apache server. But is the best? Are there any third party tools which can help me to divert traffic to PHP and Java apps based on the port in the http request?
Port nos for PHP app is 80 and Java app is 9000.
Regards,
Suraj
assuming both ports are forwarded correctly and Apache is only listening for traffic on port 80 and java is only listening on 9000 then going to YourIp:80 should take you to apache and YourIP:9000 should take you to the java app
For PHP app create common vhost as usally, and for Play app create reverse-proxy vhost (with other domain and/or subdomain for this), take a look at samples in docs
LoadModule proxy_module modules/mod_proxy.so
...
<VirtualHost *:80>
DocumentRoot "/path/to/your/php/app/root/folder/"
ServerName your-php-app.com
ErrorLog "/path/to/apache/logs/folder/your-php-app.com-error_log"
CustomLog "/path/to/apache/logs/folder/your-php-app.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ServerName your-play-app.com
ProxyPass /excluded !
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
</VirtualHost>
Thanks for your comment.
Yeah, I did the same thing. I am simply pointing my domain name to Apache Http server. So its using default port 80 and does not show up in urls.
Also, I am using Apache as front server for all my requests to port 9000. So, I am rerouting my requests for Play application at port 9000 through Apache port 80. It needed a change in url patterns so that play and apache specific urls can be distinguished.
Changed urls and used proxy_http_module + ProxyPassMatch directive to get the rerouting working.
Suraj

Can it's possible to make multiple server in a same domain sub-directory

It's just my project. It's growing up and I want to add a new server as a sub-directory on the same domain. Is it possible to make sub-directory like:
example.com 127.0.0.1
example.com/project1/ 127.0.0.2
example.com/project2/ 127.0.0.3
How I config a DNS or Apache to make it work?
Sounds like you want to implement a proxy which can be done with mod_proxy. I assume the sites are already running on 127.0.0.2 and 127.0.0.3 and the public frontend is on 127.0.0.1
You will need to edit the configuration files on 127.0.0.1 and either in the main configuration (for a single site) or virtual host block for a virtual host, add the ProxyPass configuration:
ProxyPass /project1/ http://127.0.0.2/
ProxyPass /project2/ http://127.0.0.3/
This will send all requests from /project1/ to http://127.0.0.2/, if you want to keep this server hidden, or it's not accessible by the public such as an internal network address you will need to set up a reverse proxy so the results are fed back to users via your public front end, so you will need to add ProxyPassReverse configuration:
ProxyPassReverse /project1/ http://127.0.0.2/
ProxyPassReverse /project2/ http://127.0.0.3/
Further to this, you will need to enable the proxy modules in your configuration files as well, these are what I have enabled for a basic reverse proxy
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
There are some other modules that could be important depending on your situation
mod_proxy_connect This handles the CONNECT function if connecting to https:// servers
mod_proxy_ftp This handles connections to FTP servers
mod_proxy_ajp This handles connections to tomcat/AJP servers
mod_headers This can modify response and request headers
mod_deflate This negotiates compression with backends
mod_proxy_html This is a 3rd party module which will rewrite HTML links to the proxy address space

switching my app from http to https

i'm working on an extranet for my school, in php and mysql, running on apache2 and using friendly urls via mod_rewrite.
I'm thinking that since there is potentially sensitive data involved, it would be better to work on an https url rather than http. The thing is: i have absolutely no experience in https. The pros, the cons and will my app actually work or will i need to modify it?
Does it also mean i have to set up something specific on the server? Will it not break the mod_rewrite rules?
Thank you for your time.
For your app, everything is the same but the URL.
But the Apache must be configured to properly handle it. Its just another VirtualHost entry in httpd-vhosts.conf, but using port 443 and...
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile "/..path../certificate.crt"
SSLCertificateKeyFile "/..path../certificate.key"
DocumentRoot ...
httpd.conf:
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
Search Google for instructions of how to create your 'testing purpose' SSL certificate.