LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-14-2013, 02:43 AM   #1
unclesamcrazy
Member
 
Registered: May 2013
Posts: 189

Rep: Reputation: 1
Run different web applications on different ports in Apache


I have two web applications which I run through apache.

I want to run them on two different ports i.e. 80 & 34.

I have made both ports set as LISTEN in httpd.conf
I have created virtual hosts for both of them and defined them in /etc/hosts file.

The problem is I can open port 34 project using port 80 virtualhost.

Example, one project is on port 80 and other is on 34.
The server name is wa1 for port 80 project and wa2 is for port 34 project.
If I run http://wa1 in browser, it opens port 80 project, it is fine.
but if I run http://wa2 in browser, it opens default Apache page.
If I want to run "port 34 project", I have to run http://wa2:34

Can't I run port 34 project using only http://wa2 ?

as well as I can run port 34 project using http://wa1:34
but port 80 project is strictly running by only http://wa1

Can't port 34 be run using only one and only one url.
Please help.

Regards
Sam

Last edited by unclesamcrazy; 12-14-2013 at 02:52 AM.
 
Old 12-14-2013, 04:11 AM   #2
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
I can't think of any way you can do that.
You see, default port for http is 80. Every web browser assumes that a http request shall be sent to that port. So the web server actually gets a call on port 80 - it does not itself transfer "http" to port 80.

Maybe there is a possibility using something like advanced load balancers or possibly policy-based routing, but honestly I think not - and any way, that is definitely not easy to set up.
 
Old 12-14-2013, 12:54 PM   #3
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
As pingu says, when you type http:// into your browser, you're explicitly telling it to use port 80 because http runs on port 80. using http://wa2:34 overrides this and tells your browser to use port 34.

Honestly, the easiest thing to do is probably put in an HTTP direct (possibly using mod_rewrite -- it's been awhile since I've doen this) to redirect http://wa2 to http://wa2:34. That way you don't have to remember the :34 in the URL string.
 
Old 12-14-2013, 12:59 PM   #4
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Is there a reaason for why wa2 has to use a different port?
 
Old 12-15-2013, 11:54 PM   #5
unclesamcrazy
Member
 
Registered: May 2013
Posts: 189

Original Poster
Rep: Reputation: 1
Thanks for all replies.

Quote:
Originally Posted by pingu View Post
Is there a reaason for why wa2 has to use a different port?
Becuse of different port number, The project will be more secure. We have to protect the project from LAN users.

A unique virtualhost name will do the same thing but if port number will be different too,it will increase the security and it will be safe from LAN users.

The project must not be shared with other users of the other projects of same LAN or intranet.

but it seems like if somehow they know the port number, they do not need to know the unique virtual hostname.

They just have to run the their project's url with port 34 and they will reach to the project.

The project is not being made for any outside client, it is a company application which is being created for company's employees.

That's why we have to secure it from company's employees.

If you have any better idea please share.

--Kind Regards
Sam

Last edited by unclesamcrazy; 12-15-2013 at 11:55 PM.
 
Old 12-16-2013, 01:21 AM   #6
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Quote:
Originally Posted by unclesamcrazy View Post
Becuse of different port number, The project will be more secure. We have to protect the project from LAN users.
Just be aware that this prevents accidental access, it doesn't stop evil guys. It's very easy to find open ports on a server.
If you need to protect it maybe consider adding password protection if you haven't done that already.
It's pretty easy to do, here's one short guide: http://www.cyberciti.biz/faq/howto-s...htaccess-file/
Quote:
but it seems like if somehow they know the port number, they do not need to know the unique virtual hostname.
They just have to run the their project's url with port 34 and they will reach to the project.
When url is not in vhosts, then apache serves the first available vhost for the port.
So just add a "default" vhost for port 34 before your wa2, then users must know the actual virtual hostname to find wa2.
 
1 members found this post helpful.
Old 12-16-2013, 04:01 AM   #7
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
I now realize that your original question contradicts what you want to achieve!
Quote:
Can't I run port 34 project using only "http://wa2" ?
Quote:
Becuse of different port number, The project will be more secure.
Read these two sentences carefully and you'll see what I mean! :-)
 
Old 12-16-2013, 07:06 AM   #8
unclesamcrazy
Member
 
Registered: May 2013
Posts: 189

Original Poster
Rep: Reputation: 1

Right now I am going with .htaccess password method. "If you know the password, project is all yours."
Quote:
Originally Posted by pingu View Post
I now realize that your original question contradicts what you want to achieve!
It looks like paradox.
I was thinking at that time, if port number is not used in the url so it will not give a hint to employees that different port number can be used to secure this project as well as I did not want to disclose my main idea (again security purpose) but it pushed you two on wrong track and I could not get the solution.

That's why I have cleared the purpose in post #5
As we have discussed this again so can you please explain the meaning of this functionality
Code:
When url is not in vhosts, then apache serves the first available vhost for the port.
So just add a "default" vhost for port 34 before your wa2, then users must know the actual virtual hostname to find wa2.
I could not understand this. What should I do to achieve this?
 
Old 12-16-2013, 07:21 AM   #9
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Quote:
Originally Posted by unclesamcrazy View Post
I was thinking at that time, if port number is not used in the url so it will not give a hint to employees that different port number can be used to secure this project
Ah, but if you get there without typing in the port number then it's the same as just use port 80!
Quote:
When url is not in vhosts, then apache serves the first available vhost for the port.
So just add a "default" vhost for port 34 before your wa2, then users must know the actual virtual hostname to find wa2.
I could not understand this. What should I do to achieve this?
In your vhosts file (default "/etc/httpd/conf.d/vhosts.conf") add a new vhost at the beginning of the file, like this:
Code:
<VirtualHost *:34>
#-----------------------  Default  ----------------------------
        ServerAdmin webmaster@localhost
        ServerName default
        DocumentRoot /var/www/default
        <Directory />
                AllowOverride None
                Order allow,deny
                deny from all
        </Directory>
        <Directory /var/www/default>
                Options -Indexes
                AllowOverride None
                Order allow,deny
                deny from all
        </Directory>
</VirtualHost>
It must be the first vhost for port 34, then apache will serve this one as the default.
The "deny from all" will return a "Not allowed", you can of course change this if you want.
 
Old 12-16-2013, 11:52 AM   #10
yooden
Member
 
Registered: Dec 2013
Distribution: Debian Wheezy/Jessie # XFCE
Posts: 53

Rep: Reputation: Disabled
Quote:
Originally Posted by unclesamcrazy View Post
Can't I run port 34 project using only http://wa2 ?
I'd say that is impossible. You use the resolver to find the address of wa2, and the resolver doesn't know jack about ports, it only knows about IP addresses. It cannot send you to a different port, and (as already mentioned) you will be sent to port 80 by default.

What you could do is redirect from wa:80 to wa:34, but that would defeat the purpose. Speaking of the purpose:

Quote:
Becuse of different port number, The project will be more secure.
This is very likely wrong. Your method adds almost nothing to security, and will most probably decrease security. Find a better way to protect the project.

Note: Please use more descriptive examples next time.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to run phpMyAdmin alongside Tomcat web applications LXer Syndicated Linux News 0 09-14-2011 01:10 PM
LXer: SELinux - Highly Secured Web Hosting for Python-based Web Applications LXer Syndicated Linux News 0 05-28-2008 07:30 AM
php4 & apache installed but will not run web pages with scripts oberon-ken-obi Linux - Newbie 5 07-06-2004 08:00 AM
New Web Applications to Apache-Tomcat Web sarathmohan Linux - Software 0 10-02-2003 02:59 AM
uninstalling applications via ports... jd121 *BSD 2 08-24-2003 09:43 PM


All times are GMT -5. The time now is 05:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration