简体   繁体   English

如何为OpenCPU应用程序设置域名?

[英]How do I set a domain name to an OpenCPU app?

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/ . 我有一个运行OpenCPU的Ubuntu 18.4 LTS服务器,并且能够通过将我的浏览器指向地址http://myip/ocpu/library/myapp/www/来运行应用程序myapp I wish to make the app available via the domain name mydomain.name , and have set up DNS records to point to myip . 我希望通过域名mydomain.name提供应用程序,并设置DNS记录以指向myip

On the server side, I created a file /etc/apache2/sites-available/myapp.conf , which looks like 在服务器端,我创建了一个文件/etc/apache2/sites-available/myapp.conf ,看起来像

<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 . 但是, sudo systemctl reload apache2会抛出一个错误,因为它无法找到documentRoot /ocpu/lib/myapp/www In fact, there is no directory ocpu on the server. 实际上,服务器上没有目录ocpu

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 . 我怀疑我需要在/etc/opencpu/server.conf.d设置一个.conf文件,但是这些文件的结构与上面给出的myapp.conf看起来非常不同,我没有看到一个条目ServerName

How do I redirect mydomain.name to http://myip/ocpu/library/myapp/www/ ? 如何将mydomain.name重定向到http://myip/ocpu/library/myapp/www/

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: 如果该站点可通过http://myip/ocpu/library/myapp/www/但应通过http(s)://mydomain.name您只需在apache2配置中创建一个代理条目,如下所示:

<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 注意 :您可能必须启用代理模块: sudo a2enmod proxysudo a2enmod proxy_http

This will serve the website http://myip/ocpu/library/myapp/www/ on mydomain.name . 这将在mydomain.name上提供网站http://myip/ocpu/library/myapp/www/

Make sure to restart apache2 ( sudo service apache2 restart ) after editing the configuration and enabling the module(s). 确保在编辑配置并启用模块后重新启动apache2( sudo service apache2 restart )。

Sources: https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension 来源: https//www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM