Reputation: 339
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”
Upvotes: 2
Views: 805
Reputation: 339
Solved it by creating a seperate Vhost as proxy for the Node js. Named it socket.mydomain.nl and everyrthing works well
Upvotes: 1