logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: two virtualhosts that point to the same website
Author
techmaticsdev



Joined: 23 Aug 2019
Posts: 3
Location: Christchurch, NZ

PostPosted: Mon 26 Aug '19 0:34    Post subject: two virtualhosts that point to the same website Reply with quote

Hi,

My name is Nathan. I'm just learning to use apache.

On a rackspace server, I am running apache 2.4.27. Up until recently the apache has had just one virtualhosts file for the website. However I am wanting to run two domains with it, because the server communicates with an app, which has been upgraded to point to another domain. Lets call domain A OldServer.com and domain B NewServer.com
In order for the old app to work, it needs to point to Domain A, however the new version of the App points to Domain B.
In order to do this, I set up two virtual host files. one that would be using OldServer.Com and another using NewServer.com

However when loading the New server, which points to the same folder as the Old server, I have an issue with session data. Specifically, when loading data for a form in jQuery, the call to the ajax controller returns no data. I have been able to narrow down the issue to be that these files require a session variable to be set to write a query for MySQL.

What would be the best way to handle the situation?

Thanks in advance for any help you can provide.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Mon 26 Aug '19 19:37    Post subject: Reply with quote

I don't know if this will help with the session problem but it won't hurt to try right?

How about just adding a second domain to the one vhost with ServerAlias directive?

Code:
<VirtualHost *:Port>
  ServerName  OldServer.Com
  ServerAlias NewServer.com
  DocumentRoot /path/to/someplace
  ...
</VirtualHost>


see http://httpd.apache.org/docs/2.4/mod/core.html#serveralias
Back to top
techmaticsdev



Joined: 23 Aug 2019
Posts: 3
Location: Christchurch, NZ

PostPosted: Wed 28 Aug '19 2:01    Post subject: Reply with quote

Thanks for the reply glsmith.

I added the serveralias directive:
- the new domain WORKS. thumbsup
- The behavior looks the same - unable to fetch data from ajax call.
Back to top
mraddi



Joined: 27 Jun 2016
Posts: 149
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Wed 28 Aug '19 9:01    Post subject: Reply with quote

Hello to NZ Very Happy

no solution but some ideas what to check:
* Are the cookie-parameters set correctly? As it is the same code for OldServer.Com and NewServer.Com it might be that the code sets the cookie only for OldServer.Com (might be checked in browser's developer-console).
* Are you trying to access OldServer.Com using AJAX from within the browser when NewServer.Com is opened? Then it might that Same-Origin-Policy is violated and therefore the response is discarded. (see https://d-mueller.de/blog/cross-domain-ajax-guide/ and others)

Greetings
Matthias
Back to top
techmaticsdev



Joined: 23 Aug 2019
Posts: 3
Location: Christchurch, NZ

PostPosted: Mon 02 Sep '19 1:01    Post subject: Reply with quote

There are a bunch of cookies related to google which are exactly the same. The phpsessid is different between the old site and the new site. What am I looking at here anyway?

I had the problem of same-origin before but was able to get around it thankfully. All it required was to add a line to the vhosts file.

I wonder if the session is accessing the oldsite's session data?
Back to top


Reply to topic   Topic: two virtualhosts that point to the same website View previous topic :: View next topic
Post new topic   Forum Index -> Apache