Using IIS and Apache on same server - apache

I have a server running both Apache and IIS. IIS is using port 80 and every domain name hosted on the server using iis works fine. Now i also have apache running and is listen on port 8080. Is is possible that i have a domain www.example.com and it uses Apache, but i do not have to type www.example.com:8080 to get the site , but i go on www.example.com to get the site. I can host php on iis and all that but i want to use Apache for that website. I am currently this on httpd.conf
<VirtualHost *>
DocumentRoot "${path}/data/localweb/example"
ServerName www.example.com
<Directory "${path}/data/localweb/example">
Options FollowSymLinks Indexes
AllowOverride All
Order allow,deny
Allow from all
#Deny from all
Require all granted
</Directory>
# Other directives here
</VirtualHost>

If you have the ability to use multiple IP address oh the web server you could bind the IIS site to one on port 80 and the Apache site to port 80 on the second. If it's a VM you can just add another virtual network interface, if it's a physical server you can add a new network card.
If you only have one IP address you could setup ARR+ URL rewrite to use the IIS server to act as a reverse proxy to the apache site.

Related

WAMP Server cannot be accessed through local network [duplicate]

So I set up a few virtual hosts with unique urls and they work just fine on the desktop. However, when I connect a mobile device on the network, it can't seem to access anything properly but the default localhost virtualhost and that's only when it's the only virtualhost I have up.
My setup and coding is pretty much this except with a different site title
wamp server 3.0 virtual host on another device
and while that solution redirects me to my unique url, it has a lack of images on a default wordpress website.
Has anyone managed to get mobile devices fully accessing links other than on localhost?
Since I posted the answer you referenced, I have decided upon a simpler solution.
What the actual problem is
Because we cannot fiddle with the configuration of a phone like we can with a PC, the phone can never find the domain name we create in our Virtual Host definition on the Server machine, because it does not exist in any DNS Server for it to locate the IP Address in, and a DNS Server is the only place a phone can look, unless it is jail broke.
If you wanted to access one of your Virtual Hosts domains from another PC you could just add a line like this into the HOSTS file on the other PC like this.
192.168.0.10 example.local
But you cannot do that on a phone/tablet.
What Apache expects to be able to asssociate a request to a Vhost
When we create an Apache Virtual Host, we are actually telling Apache to look at the domain name on the incoming connection and match that domain name to a ServerName that exists in one of our multiple Virtual Hosts definitions.
But if we use for example example.local as our virtually hosted domain when we attempt to connect to that from our phone, the phone does a DNS Lookup and does not find that domain and therefore cannot get its ip address.
The simplest way to get round this is:
Assuming we do not have access to adding record to a DNS Server we have to come up with a different solution.
The simplest of these is to use the IP Address of the PC running the WAMPServer(Apache) server and a specific port number. So thats a different port number for each of our sites we want to use from a phone.
So how do we do this
Add the new listening port to httpd.conf like so after the 2 existing Listen statements
WAMPServer 3: Do this using the menus, not by doing a manual edit on httpd.conf
right click wampmanager-> Tools -> Add listen port for Apache
#Listen 12.34.56.78:80
Listen 0.0.0.0:80
Listen [::0]:80
Listen 0.0.0.0:8000
Listen [::0]:8000
Suggested httpd-vhosts.conf file
#
# Virtual Hosts
#
# Always keep localhost, and always first in the list
# this way a ramdom look at your IP address from an external IP
# maybe a hack, will get told access denied
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
# The normal Vhost definition for one of our sites
<VirtualHost *:80>
ServerName example.local
DocumentRoot "c:/websrc/example/www"
<Directory "d:/websrc/example/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
# Access example.dev from phone for testing
<VirtualHost *:8000>
ServerName example.local
DocumentRoot "c:/websrc/example/www"
<Directory "d:/websrc/example/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
# assuming yoursubnet is 192.168.0.?
# allow any ip on your WIFI access
Require ip 192.168.0
</Directory>
</VirtualHost>
Restart Apache from wampmanager after completing these edits.
Now you test this from the WAMPServer PC by using the ServerName i.e example.dev and from the phone using the ip of the PC running WAMPServer with the port number i.e. 192.168.0.10:8000
Apache will find the correct code to serve from both requests.
If you want more than one Virtual Host to be accessible from your phone you just duplicate this idea and change the port number for each new site, lets say you would use 8001,8002,8003 etc. For as many sites as you want to access.
You may also have to amend your firewall to allow access on http on port 8000, or whatever port you pick to use

How can I change all my links on my Apache site to look for port 8080 instead of 80 after changing my site from 80?

My local Apache environment, on XAMPP, was set up to listen on port 80. I now changed it to listen to port 8080. my site now works on port 8080. I have to go to mysite.local:8080 to make it work, which is fine. The only problem is when I click a link it goes to mysite.local/page instead of mysite.local:8080/page and the page does not work. Also, some of my pages that use a log in require me to NOT use 8080 in the url so I have to use mysite.local/admin instead of mysite.local:8080/admin so I am constantaly swithing between adding the port number in the url and taking it away for some other pages. Is there a way where I can make it where I don't have to specify port number on any of the pages. This happened after installing IIS by the way.
My vhost page now looks like the below:
<VirtualHost mysite.local:8080>
DocumentRoot "C:\repos\www.mysite.org\web"
ServerName mysite.local
ErrorLog "logs/mysite-error.log"
CustomLog "logs/mysite-access.log" common
<Directory "C:\repos\www.mysite.org\web">
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
The problem is, that after you changed Apache to listen on 8080 Apache does not even see traffic on :80 (and that's where default HTTP traffic goes).
As you said that you have IIS listening on :80, the only way to solve your problem is to make IIS act as a reverse proxy that would forward all the traffic that should be meant for Apache to Apache.

Apache reverse proxy, one server, multiple domains

I am trying to manage 2 domains with one server (running proxmox with several CT), I am using reverse proxy but seems to be wrong.. here's my configuration:
Let's say we have the main server running proxmox where I managed IPTables to redirect port 80 to the port 80 of my first container (CT01) and port 8109 to port 80 of my second container (CT02).
While using the port in my browser, everything is working well, and I am able to reach each container.
I bought 2 domain names, one for my private server (CT01) and another one for a business server (CT02). I associated both of the domain to my server address, and while typing one or another of them I am redirected to CT01 (normal, browser is running the address to the default port).
So now I tried to use reverse proxy in order to redirect to the desired server (DomainA -> CT01, DomainB -> CT02), I created 2 files in /var/apache2/sites-available/ :
/var/apache2/sites-available/domainA.com:
<VirtualHost *:80>
ServerName domainA.com
DocumentRoot /var/www/
</VirtualHost>
/var/apache2/sites-available/domainB.com:
<VirtualHost *:80>
ServerName domainB.com
ProxyPreserveHost On
ProxyRequests On
ProxyPass / http://x.y.z.h:8109/
ProxyPassReverse / http://x.y.z.h:8109/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
Then I runned a2ensite domainA.com and a2ensite domainB.com. I restarted my apache service.
But nothing have changed: both my domainA and domainB redirect me to the same container (CT01).
Any idea?
What i may suggest is doing a new CT just to host a proxy (nginx for example) that will route the requests to one or the other site depending of the Host: field value of the HTTP request. This may be a little bit overkill if it's just for two sites, but when you want to have more, it can be very useful. Plus the NGinx can be used to cache, etc.
Let me know if you are interested. I know a tutorial that you may follow, but it's in french : http://blog.ganbaranai.fr/2013/08/il-etait-une-fois-proxmox-derriere-une-ip-unique/
Hope it helps.
Regards,

Remove Port Number from URL Thin Server 1.5 with Rails 3

I have a small Rails app currently being served (dev and production) by Thin server on port 3000, on a Debian box that also has apache2 running, serving PHP applications.
I am not certain if this is even possible given the current setup but is there a way to remove the port number from the rails app url but still have Thin listening from the same port so not to bump into apache?
Current
https://my-rails-site:3000/
Proposed
https://my-rails-site/
Or should I just use something like Passenger?
OR
mod_proxy?
You want to remove the port number from the URL and have your app listening on a non-standard port at the same time? Then you must have Apache/Nginx must listen on the standard port and proxy requests to your app's non-standard port. You need to either setup Apache with mod_proxy or Nginx with proxy_module.
If you just want your app to be accessible over a standard port then you can just use Phusion Passenger, that makes things very easy.
If you are using passenger here is what I had to use to get it working on www.mysite.com without using www.mysite.com:80 on a centos server:
In etc/httpd/conf the key was to uncomment the NameVirtualHost *:80 and change the * to my server's IP address. Make sure Listen 80 is uncommented. Also add your ip to the VirtualHost tag. It must be running on port 80, not 8080 or something of your choosing.
NameVirtualHost xx.xx.xx.xx:80
Listen 80
<VirtualHost xx.xx.xx.xx:80>
ServerName www.mysite.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/vhosts/mysite.com/httpdocs/public/
<Directory /var/www/vhosts/mysite.com/httpdocs/public/>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>

How to I point multiple URLs to the right directory?

I have a VPS running CentOS 5. I want to point multiple domains at the same VPS (point them at the same IP), but serve up distinct websites for each domain.
So, the setup I want is like this:
site1.com ----> 127.0.0.1 ----> /var/www/html/site1.com/
site2.com ----> 127.0.0.1 ----> /var/www/html/site2.com/
I've tried setting up virtual hosts through the CentOS GUI for Apache, but they don't seem to be working. Only the first virtual host added will work (i.e. If I add site1.com first, both domains direct to that site. If I add site2.com first, both domains direct to that site.)
What might I be doing wrong? Is there an effective step-by-step tutorial for newcomers to get me started?
Update
Please remember, I have little to no experience working with CentOS and Linux ... but I'm learning.
To those who asked to see the directives I'm using, here's what CentOS added to the bottom of /etc/httpd/conf/httpd.conf when I used the built-in Apache GUI:
<VirtualHost skylarkapp.com:80>
DocumentRoot /var/www/html/skylarkapp.com
<Directory "/var/www/html/skylarkapp.com">
allow from all
Options +Indexes
</Directory>
ServerName skylarkapp.com
</VirtualHost>
<VirtualHost eamann.com:80>
DocumentRoot /var/www/html/eamann
<Directory "/var/www/html/eamann">
allow from all
Options +Indexes
</Directory>
ServerName eamann.com
</VirtualHost>
At the moment, all traffic to both skylarkapp.com and eamann.com on this system direct to the content of /var/www/html/skylarkapp.com.
Also, I'm using my Windows hosts file to manually point eamann.com to this server (204.92.23.6) because I'm in the process of migrating a live site. I want to get things working on the server before I actually move things from one box to another.
Name-based virtual hosts must be turned on explicitly with NameVirtualHost *:80. See http://httpd.apache.org/docs/2.2/vhosts/name-based.html
This line:
<VirtualHost eamann.com:80>
won't work since eamann.com won't resolve to your CentOS server's IP address (only your Windows machine resolves eamann.com to 204.92.23.6). Try making apache listed on any IP by replacing with:
<VirtualHost *:80>
You probably also want:
ServerAlias www.eamann.com
to allow visitors to www.eamann.com to see the site as well. Restart apache after making these changes:
service httpd restart