LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 10-08-2012, 01:59 PM   #1
agriz
Member
 
Registered: Nov 2011
Posts: 174

Rep: Reputation: Disabled
Subdomain Problem


Hi

I created the following in apache
Code:
<VirtualHost *:8080>
ServerName subdomain.domain.com
ServerAlias subdomain.*
DocumentRoot /var/www/html/subdomain
</VirtualHost>
And then, in domin.com.hosts file I added the following line.

Quote:
subdomain IN A xxx.xx.xx.xx
and in nginx, i added the following

server {
listen 80;
server_name subdomain.domain.com;
.........
}

But when i try to access it is not working.
What am i missing / doing wrong?
 
Old 10-08-2012, 02:20 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
at what point do you tell nginx to connect to port 8080? Why are you using port 8080 in the first place? Do you have a Listen statment in apache for it? Is it listening from a network check?
 
Old 10-09-2012, 01:54 AM   #3
agriz
Member
 
Registered: Nov 2011
Posts: 174

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by acid_kewpie View Post
at what point do you tell nginx to connect to port 8080? Why are you using port 8080 in the first place? Do you have a Listen statment in apache for it? Is it listening from a network check?
I have two domains on this server.
But this subdomain is not loading.
 
Old 10-09-2012, 02:06 AM   #4
arun5002
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 549
Blog Entries: 5

Rep: Reputation: Disabled
Quote:

I have two domains on this server.
But this subdomain is not loading.




Since you are running your virtualhost in port 8080.Default apache listen on port 80.Have you made entry in apache httpd.conf to listen to virtualhost 8080

Listen 8080 --HTTPD.CONF

<VirtualHost *:8080>
..
 
Old 10-09-2012, 02:11 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
Quote:
Originally Posted by agriz View Post
I have two domains on this server.
But this subdomain is not loading.
repeating yourself is not useful. Please provide new useful information that answers the questions asked.
 
Old 10-09-2012, 02:17 AM   #6
agriz
Member
 
Registered: Nov 2011
Posts: 174

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by acid_kewpie View Post
repeating yourself is not useful. Please provide new useful information that answers the questions asked.
Yes, I have done that.
I didn't mean to repeat.

I made apache to listen. I guess otherwise, the two main domains won't work.
Obviously, for the first time, I spent lot of time to make it work. (This apache + nginx) I got some help here too.

Now i am struck in subdomain. Please let me know what kind of information do you need?

** Nginx is handling js,css,images (static files)
** Apache is handling php files.

Nginx is listening on port 80
Apache is listening on port 8080
 
Old 10-09-2012, 02:20 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
so again, where in your nginx config do you reference port 8080? Actually, you need to ignore nginx for now... test using the domain purely with apache.

to avoid DNS mess etc, run:

curl -H "Host: subdomain.domain.com" 127.0.0.1:8080

and see what that does. Also check the contents of your access and errror logs, especially error on startup.
 
Old 10-09-2012, 02:29 AM   #8
agriz
Member
 
Registered: Nov 2011
Posts: 174

Original Poster
Rep: Reputation: Disabled
location / {
proxy_pass http://127.0.0.1:8080;
}

This is found in nginx.

This is the output of curl

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.subdomain.domain.com/">here</a>.</p>
</body></html>
 
Old 10-09-2012, 02:34 AM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
No idea what's providing that back to you, but clearly there is no coverage for that domain name in your apache config, so either create the www ServerAlias or stop that redirect occurring.
 
Old 10-09-2012, 03:08 AM   #10
agriz
Member
 
Registered: Nov 2011
Posts: 174

Original Poster
Rep: Reputation: Disabled
I have these lines in domain.com

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

I guess this one is making the subdomain.domain.com to www.subdomain.domain.com

But the document root is "subdomain" which has also one htaccess file there.
Why should it take the htaccess from domain.com?
 
Old 10-09-2012, 03:11 AM   #11
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
does /var/www/html/subdomain the .htaccess file?
 
Old 10-09-2012, 03:12 AM   #12
agriz
Member
 
Registered: Nov 2011
Posts: 174

Original Poster
Rep: Reputation: Disabled
Is virtualhost order in htaccess important?

This is the order in htaccess

domain.com
subdomain.domain.com
domain2.com

---------- Post added 10-09-12 at 03:12 AM ----------

Quote:
Originally Posted by acid_kewpie View Post
does /var/www/html/subdomain the .htaccess file?
RewriteEngine On
RewriteBase /subdomain

ErrorDocument 404 /404.php
 
Old 10-09-2012, 03:13 AM   #13
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
if there is no suitable matching virtualhost for the host requested then the first virtualhost in the list is used.
 
Old 10-09-2012, 03:19 AM   #14
agriz
Member
 
Registered: Nov 2011
Posts: 174

Original Poster
Rep: Reputation: Disabled
<VirtualHost *:8080>
DocumentRoot "/var/www/html/domain"
ServerName domain.com
<Directory "/var/www/html/domain">
allow from all
Options -Indexes
</Directory>
ServerAlias *.domain.com
</VirtualHost>

<VirtualHost *:8080>
ServerName subdomain.domain.com
ServerAlias subdomain.*
DocumentRoot /var/www/html/domain/subdomain
</VirtualHost>

<VirtualHost *:8080>
DocumentRoot "/var/www/html/domain2"
ServerName domain2.com
<Directory "/var/www/html/domain2">
allow from all
Options -Indexes
</Directory>
ServerAlias *.domain2.com
</VirtualHost>
 
Old 10-09-2012, 03:25 AM   #15
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
why are you using a virtualhost for a subdomain that's in a directory underneath the main domain?

This looks handy: http://stackoverflow.com/questions/9...older-redirect
 
  


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
Create webmail subdomain on Plesk master domain. (reserved subdomain) fruitwerks Linux - Server 0 08-11-2010 03:08 PM
subdomain redirection problem with virtualhost jhwilliams Linux - Networking 2 05-21-2008 05:21 PM
SSL and subdomain problem Wim Sturkenboom Linux - Server 3 07-02-2007 06:33 AM
SubDomain Problem - Directories? Quincy Wisdom General 0 07-04-2004 10:46 PM
Subdomain and hosting problem AZIMBD03 Linux - Newbie 4 12-07-2003 04:09 AM


All times are GMT -5. The time now is 01:58 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration