Apache hosting php website and proxy for node js CORS

My setup:

An apache 2.22 virtual host running a php chat reachable at chat.mydomain.nl. The root folder /var/www/NEWchat/.

A Node js server not serving any webcontent but for passing information and signalling. The node js server has the name server.js, listens on port 1900 and resides in a folder at /var/www/socket.

I just want to be able to proxy requests made by clients to the socketserver. In the javascript on the client the address of the socketserver is: socket = io.connect('http://mydomain.nl:1900');

without proxying it all works!

Then i edit the directives off the virtual host where the website chat.mydomain.nl is running on like:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
documentRoot /var/www/NEWchat
<Directory "/var/www/NEWchat">
allow from all
Options +Indexes
</Directory>
ServerName chat.mydomain.nl
Alias /uploads /var/uploads
ErrorLog /var/mydomainlog/log.log
LogLevel emerg
SSLEngine off
SSLCertificateFile /etc/letsencrypt/live/chat.mydomain.nl/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/chat.mydomain.nl/privkey.pem
SSLCACertificateFile /etc/letsencrypt/live/chat.mydomain.nl/chain.pem
ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>
ProxyPass /socket http://localhost:1900
ProxyPassReverse /socket http://localhost:1900
<Location /socket >
    Order allow,deny
    Allow from all
</Location>

Restart the apache and pointing from the clients to:

socket = io.connect('http://chat.mydomain.nl:1900');

And al i get is :

“No 'Access-Control-Allow-Origin' header is present on the requested resource”

Answers


Solved it by creating a seperate Vhost as proxy for the Node js. Named it socket.mydomain.nl and everyrthing works well


Need Your Help

How should I be searching through a multi dimensional array in php

php arrays search

I have a standard multi dimensional array listed below that will house my customers faq articles. The articles will include a title, a description and various tags per article. I am trying to setup a

How to Convert an SVN import to an Android project

android eclipse svn

I have checked out the repo of an Android application using Subeclipse (File > Import > Checkout from SVN). But in Eclipse it just shows up as a folder. It can't be run as an android project. How t...