Reputation: 408
I have a Ubuntu 18.4 LTS server running OpenCPU
, and am able to run the application myapp
by pointing my browser to the address http://myip/ocpu/library/myapp/www/
. I wish to make the app available via the domain name mydomain.name
, and have set up DNS records to point to myip
.
On the server side, I created a file /etc/apache2/sites-available/myapp.conf
, which looks like
<VirtualHost *:80>
ServerName mydomain.name
DocumentRoot /ocpu/lib/myapp/www
LogLevel info
ErrorLog /var/log/myapp/apache_error.log
CustomLog /var/log/myapp/apache_access.log combined
</VirtualHost>
However, sudo systemctl reload apache2
throws an error since it cannot find the documentRoot /ocpu/lib/myapp/www
. In fact, there is no directory ocpu
on the server.
I suspect that I need to set up a .conf
file in /etc/opencpu/server.conf.d
, but the structure of those files look very different from myapp.conf
as given above, and I do not see an entry for a ServerName
.
How do I redirect mydomain.name
to http://myip/ocpu/library/myapp/www/
?
Upvotes: 2
Views: 460
Reputation: 1917
If the site is available through http://myip/ocpu/library/myapp/www/
but should be available through http(s)://mydomain.name
you can simply create a proxy entry in your apache2 configuration like this:
<VirtualHost *:80>
ServerName mydomain.name
ProxyPreserveHost On
ProxyPass "/" "http://myip/ocpu/library/myapp/www/"
</VirtualHost>
Note: You may have to enable the proxy module(s): sudo a2enmod proxy
& sudo a2enmod proxy_http
This will serve the website http://myip/ocpu/library/myapp/www/
on mydomain.name
.
Make sure to restart apache2 (sudo service apache2 restart
) after editing the configuration and enabling the module(s).
Upvotes: 4