0

I have set up staging and live site on the same machine with different document root as follows:

  1. mysite : Staging site without ssl
  2. mysite_live: Live site with ssl enabled

Both the sites have there own databases with same name as that of the document root respectively.

Site Urls are:

  1. staging.mysite.org : Staging site
  2. mysite.org : Live site

Whenever I try to visit my live site with the url: mysite.org, it shows me the staging site pages and in the url it shows the http://www.mysite.org/. From the URL it looks like the it does not take the https by default. If I type it as: https://www.mysite.org/, this works and I get live site.

If I visit staging.mysite.org, it shows me the staging site page. this means the staging url is working fine.

I am not getting why this is happening. And on every click on any link on live site opens the staging site pages but in the url it looks like it is live site only because the url remains as http://www.mysite.org/.

Virtualhosts configurations as as follows:

  1. staging site
<VirtualHost *:80>
    SuexecUserGroup "#1001" "#1001"
    ServerName staging.mysite.org
    DocumentRoot /home/mysite/web/public/mysite
    UserDir /home/mysite/homes/*/web/public
    CustomLog /home/mysite/logs/access_log combined
    ScriptAlias /cgi-bin/ /home/mysite/cgi-bin/
    ScriptAlias /fcgi-bin/ /home/mysite/fcgi-bin/
    <Directory /home/mysite/web/public/mysite>
        Options -Indexes IncludesNOEXEC FollowSymLinks -MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    <Directory /home/mysite/cgi-bin>
        Order allow,deny
        Allow from all
    </Directory>
    <Directory /home/mysite/fcgi-bin>
        Order allow,deny
        Allow from all
    </Directory>
    SSLEngine off 
</VirtualHost>
  1. Live site
<VirtualHost *:80>
    DocumentRoot "/home/mysite/web/public/mysite_live"
    ServerName mysite.org
    <Directory "/home/mysite/web/public/mysite_live">
        AllowOverride All
        Order allow,deny
        allow from all
        Options +Indexes
    </Directory>
</VirtualHost>
<VirtualHost *:443>
    DocumentRoot "/home/mysite/web/public/mysite_live"
    ServerName mysite.org
    <Directory "/home/mysite/web/public/mysite_live">
        AllowOverride All
        Order allow,deny
        allow from all
        Options +Indexes
    </Directory>
    SSLEngine on
    SSLCertificateFile /home/mysite/etc/SSL/mysite.org.crt
    SSLCertificateKeyFile /home/mysite/etc/SSL/mysite.key
    SSLCACertificateFile /home/mysite/etc/SSL/mysite.org.crt
</VirtualHost>

I think there is some issue with the configuration part. but not getting what it is.

1 Answer 1

1

You don't have a ServerAlias for www.mysite.org in your live site config, so the webserver doesn't know how to serve content for that name, and falls back to the default site (which is presumably the staging site). It's serving correctly for HTTPS because you only have one HTTPS vhost, which is the live site.

2
  • Thanks womble. I resolved this issue. The problem was with the file names. I am using Joyent servers, so was creating virtual hosts using UI provided by Joyent. While debugging, I found that the virtual hosts settings created using joyent ui, are getting stored in $USER file which has higher priority than the custom virtual host files. So, I created a separate cutom file on server config and named it in such way that the priority for live site will be higher than that of the staging site. Mar 30, 2012 at 11:35
  • 1
    The correct solution is to add ServerAlias www.mysite.org to the production <VirtualHost> stanza.
    – womble
    Mar 30, 2012 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .