Port based virtual hosts on apache - apache

httpd.conf set up as follows on an apache server:
Listen 80
Listen 78
ServerName 162.13.46.59
DocumentRoot /var/www/ftl-media
NameVirtualHost 162.13.46.59:78
<VirtualHost 162.13.46.59:78>
ServerName 162.13.46.59
DocumentRoot /var/www/vapetropolis
</VirtualHost>
However, requests to port 78 aren't working. "Oops! Google Chrome could not connect to 162.13.46.59:78".
What's wrong with this config?

Generally speaking, port numbers less than 1024 require the process to run as root. This isn't so much of a firewall issue as a security policy -- those ports are reserved for system processes.
If you want to use port 78, some configuration will be required.
Maybe this question will help?
Is there a way for non-root processes to bind to "privileged" ports on Linux?

Related

Managing multiple sites on XAMPP

I have multiple sites deployed on xampp. For now, all of the sites are using one port i.e. 80. For this reason, whenever I am logged into one of the sites, I am automatically logged out from the other and vice versa. I have looked at this article to How to run multiple websites on XAMPP on Windows. And tried to follow it but I am unable to do the needful.
I have added one more port to listen
Listen 80
Listen 8080
In my httpd-vhosts.conf I have done the following
NameVirtualHost *:8080
<VirtualHost *:8000>
DocumentRoot "F:\xampp\htdocs\mdc"
ServerName localhost:8080
<\VirtualHost>
After doing this I have turned off my xampp and then tried to restart apache and mysql. But apache is not starting
My URL is http://localhost:8080/mdc/backend/web
Note: Without doing any virtual host setting the above URL is accessible on both 80 and 8080 ports
Update 1
Herer is my httpd.conf file
This is not a fix for your issue, Here i will explain how i manage multiple websites on xampp.
First i assumes that your using windows
i always use the same port with different server names.
on : E:\xampp\apache\conf\extra\httpd-vhosts.conf (In my case i installed xampp on E drive)
i added this code
<VirtualHost *:80>
DocumentRoot "e:/xampp/htdocs/mysite1"
ServerName mysite1.flames.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "e:/xampp/htdocs/mysite2"
ServerName mysite2.flames-team.com
</VirtualHost>
And on ( C:\Windows\System32\drivers\etc\hosts) my windows host file i added this lines
127.0.0.1 mysite1.flames.com
127.0.0.1 mysite2.flames-team.com
With this approach you can access the site with a clean readable URLs
In this case if you want to see the first site just enter this URL mysite1.flames.com on browser.
Cheers
Write the closing tag </VirtualHost> instead of <\VirtualHost> in the file httpd-vhosts.conf. I did it and it worked for me.

Wamp Blocking Outside traffic

Wamp Version:2.5
Windows Version:10
Apache Version:2.4.9
Wamp is Green, and its online, and it works when i type localhost, and it work in my local network meaning anyone in my house can access the site , i already port forwarded! but when i try to access my site from outside my network it keeps loading and never works!
Virtual host
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName aaess.tk
ServerAlias www.aaess.tk
Options Indexes FollowSymLinks
<Directory "C:/wamp/www">
AllowOverride All
Require all granted <- to allow inet access
</Directory>
</VirtualHost>
Can someone please help and explain why wamp is blocking outside traffic?
Possibly your ISP is blocking port 80.
Simple Test
You could just change your Port Forwarding.
Instead of forwarding router port 80 to PC port 80, just amend the Routers Port Forwarding to forward Router port 8888 to PC's port 80.
Then access the site using http://aaess.tk:8888
Using this method you can leave your Virtual Host on port 80.
It maybe worth trying a few different port numbers, I have knows ISP's to block port 8000 and 8080 as well as these are the most frequently tried alternative port numbers.
Also if you are getting your internet connection via a central connection in an apartment block or compound of some sort. It maybe that you will not find any port that you can use as the central router will be blocking all ports other than port 80.

Multiple web servers sharing a public IP

I have two entries in my DNS: www.domain.tld and svn.domain.tld
Both point to my company's public IP address of 88.77.66.55.
I have two apache servers serving port 80 on my LAN behind that public IP. One hosts my website on 192.168.1.2 and the other hosts my SVN server at 192.168.1.3.
I would like to route the IPs to:
www.domain.tld -> 192.168.1.2
svn.domain.tld -> 192.168.1.3
Here's my current intended design, but I don't know if it's feasible so I'm looking for feedback. My router will forward all port 80 data to 192.168.1.2. Then, on that machine:
/etc/apache2/httpd.conf
---
NameVirtualHost 192.168.1.2:80
NameVirtualHost 192.168.1.3:80
<VirtualHost 192.168.1.2:80>
ServerName www.domain.tld
</VirtualHost>
<VirtualHost 192.168.1.3:80>
ServerName svn.domain.tld
</VirtualHost>
Am I using the correct mechanism to accomplish this? Can I use hostnames instead of IPs? I'd like to get some indication of issues before I start messing with configurations and cause downtime.
I think that will work. Nginx reverse proxy is another way to do this on a larger scale.

EC2 SSL not working

I'm running an EC2 micro instance (Amazon Linux) and can't seem to get ssl (https) working.
The error I'm getting in Chrome is "ERR_CONNECTION_REFUSED" (no data sent).
I've enabled HTTPS inbound traffic for the security group in my AWS console.
I added this in the /etc/httpd/conf/httpd.conf file. (example.com is a placeholder for my website)
<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
SSLEngine on
SSLCertificateFile /etc/ssl/example_com.crt
SSLCertificateKeyFile /etc/ssl/example_com.key
SSLCertificateChainFile /etc/ssl/example_com.ca-bundle
</VirtualHost>
and it didn't work.
So to test VirtualHost, I replaced it with the following:
<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://google.com/
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
Redirect permanent / https://google.com/
</VirtualHost>
http://example.com redirected to google like expected, but https://example.com didn't.
Anyone know what's the problem?
Connection refused means your server's IP stack actively rejected the incoming connection on port 443 (https) because no service is listening on port 443.
We use less and less Apache these days in my operations, because of the maturity of some other alternatives, so I may be a little rusty here, but I'm reasonably sure that your server, in spite of being configured with a way to respond to requests on port 443... is not actually listening for connections on port 443.
You probably have a listen 80 somewhere in your apache config. This will need to be accompanied by listen 443 based on httpd.apache.org/docs/2.2/bind.html:
When Apache starts, it binds to some port and address on the local machine and waits for incoming requests. By default, it listens to all addresses on the machine. However, it may need to be told to listen on specific ports, or only on selected addresses, or a combination of both. This is often combined with the Virtual Host feature, which determines how Apache responds to different IP addresses, hostnames and ports.
In addition to configuring the security group to allow the traffic over port 443, you probably also need to open port 443 on the server itself.
iptables -I INPUT 1 -p tcp --dport 443 -j ACCEPT
If that fixes the issue, then to save the configuration so that it persists after a reboot:
/sbin/service iptables save

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>