LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Subdomain Problem (http://www.linuxquestions.org/questions/linux-server-73/subdomain-problem-4175431184/)

agriz 10-08-2012 01:59 PM

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?

acid_kewpie 10-08-2012 02:20 PM

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?

agriz 10-09-2012 01:54 AM

Quote:

Originally Posted by acid_kewpie (Post 4800571)
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.

arun5002 10-09-2012 02:06 AM

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>
..

acid_kewpie 10-09-2012 02:11 AM

Quote:

Originally Posted by agriz (Post 4800962)
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.

agriz 10-09-2012 02:17 AM

Quote:

Originally Posted by acid_kewpie (Post 4800980)
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

acid_kewpie 10-09-2012 02:20 AM

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.

agriz 10-09-2012 02:29 AM

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>

acid_kewpie 10-09-2012 02:34 AM

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.

agriz 10-09-2012 03:08 AM

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?

acid_kewpie 10-09-2012 03:11 AM

does /var/www/html/subdomain the .htaccess file?

agriz 10-09-2012 03:12 AM

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 (Post 4801026)
does /var/www/html/subdomain the .htaccess file?

RewriteEngine On
RewriteBase /subdomain

ErrorDocument 404 /404.php

acid_kewpie 10-09-2012 03:13 AM

if there is no suitable matching virtualhost for the host requested then the first virtualhost in the list is used.

agriz 10-09-2012 03:19 AM

<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>

acid_kewpie 10-09-2012 03:25 AM

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


All times are GMT -5. The time now is 08:28 AM.