Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What if I want to install NAF inside a folder that is within an apache2 website #356

Closed
jimver04 opened this issue Aug 8, 2022 · 6 comments

Comments

@jimver04
Copy link

jimver04 commented Aug 8, 2022

Hi Vincent,

let us assume that I have

site1 which is an apache2 website: http://127.0.0.1:80/site1/index.php looking at c:\xampp8\htdocs\site1\index.php

and I want at

http://127.0.0.1:8080/site1/naf/index.html to have the NAF website that looks at c:\xampp8\htdocs\site1\naf\index.html.

The justification is that NAF is a part of my website, and although it is not technically related to site1 server, I want to have it within it due to code maintenance and deployment convenience issues. I want to have just one Phpstorm project instead of two.

Is it possible to configure NAF node.js server to look at a subfolder instead of root? e.g. http://127.0.0.1:8080/site1/naf/

I will try to find this out today and let you know.

Best,
Dimitrios

@vincentfretin
Copy link
Member

vincentfretin commented Aug 8, 2022

Hi, you can have your site on /site1/naf but still have the nodejs server at /socket.io. Why do you want it on /site1/naf/socket.io precisely? Do you want to host several nodejs servers on your machine? If yes, there is this specific issue about configuring the socketio path #307 but I didn't test that myself so what I'm saying in this issue may be completely wrong :)

@vincentfretin
Copy link
Member

You have two path to handle /easyrtc and /socket.io.
You probably don't need to configure a special path url on the js side actually.
The apache configuration will probably looks like something I commented here
networked-aframe/naf-janus-adapter#18 (comment)
something like this? It's been years I didn't touch apache configuration, I'm using nginx or traefik now.

ProxyPass /site1/naf/easyrtc/ ws://127.0.0.1:8080
ProxyPassReverse /site1/naf/easyrtc/ ws://127.0.0.1:8080
ProxyPass /site1/naf/socket.io/ ws://127.0.0.1:8080
ProxyPassReverse /site1/naf/socket.io/ ws://127.0.0.1:8080

@jimver04
Copy link
Author

jimver04 commented Sep 6, 2022

Hi, thanks, it wasn't difficult after all.

vrodos-multiplaying.conf -> replace with [yourdomain].conf
[myipaddress] -> Replace with your ip
5832 -> replace with your NAF port (8080 is the default I think)

Below is vhost conf file located at etc/apache2/sites-available/vrodos-multiplaying.conf

<VirtualHost *:80>
	ServerAdmin ververid@iti.gr
	ServerName vrodos-multiplaying.iti.gr
	ServerAlias www.vrodos-multiplaying.iti.gr
	ProxyPreserveHost On

    # setup the proxy
    <Proxy *>
       Order allow,deny
       Allow from all
    </Proxy>
    ProxyPass / http://[myipaddress]:5832/
    ProxyPassReverse / http://[myipaddress]:5832/

RewriteEngine on
RewriteCond %{SERVER_NAME} =vrodos-multiplaying.iti.gr
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

@vincentfretin
Copy link
Member

Hi, I'm glad you found a solution. Thanks for sharing the apache config.

@tpapaz
Copy link

tpapaz commented Feb 29, 2024

Follow up answer to the one @jimver04 posted, we picked up from where he left of :)

First of all, the above doesnt work correctly with a https domain (we used certbot for ssl certs), and NAF defaults to long polling.

With https we can also support VR headsets.

So in order for web sockets to work, you need changes in both plain and ssl Virtual Servers like below.

<VirtualHost *:80>
        ServerAdmin [your email address]
        ServerName [your domain name or subdomain]
        ProxyPreserveHost On

    # setup the proxy
    <Proxy *>
       Order allow,deny
       Allow from all
    </Proxy>


ProxyPass / http://[servers ip address]:[NAF port]/
ProxyPassReverse / http://[servers ip address]:[NAF port]/

RewriteEngine on

RewriteCond %{SERVER_NAME} =[your domain name or subdomain]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

and

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin [your email address]
        ServerName [your domain name or subdomain]
        ProxyPreserveHost On

    # setup the proxy
    <Proxy *>
       Order allow,deny
       Allow from all
    </Proxy>


ProxyPass / http://[servers ip address]:[NAF port]/
ProxyPassReverse / http://[servers ip address]:[NAF port]/

ProxyPass /socket.io http://[servers ip address]:[NAF port]/socket.io
ProxyPassReverse /socket.io http://[servers ip address]:[NAF port]/socket.io

RewriteEngine on

RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
RewriteCond %{QUERY_STRING} transport=websocket    [NC]
RewriteRule /(.*)           ws://[servers ip address]:[NAF port]/$1 [P,L]


SSLCertificateFile .......... [This is already filled up by your existing setup]
SSLCertificateKeyFile .......... [This is already filled up by your existing setup]
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Hope it helps anyone that searches.
Thanks @vincentfretin for your work on NAF
and thanks @jimver04 for initial codebase :)

@vincentfretin
Copy link
Member

Thanks @tpapaz for the additional information.
For those looking for the same with nginx, I have a full configuration in #244 and also added additional comments recently there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants