Changes

From SME Server
Jump to navigationJump to search
1,615 bytes added ,  10:38, 29 January 2019
add section about port redirect for each app run in one specific port
Line 100: Line 100:  
==Test==
 
==Test==
 
  node -v
 
  node -v
 +
 +
== Port Redirect for each application==
 +
Each application you build must run on a different port. Configure that way in app.js file.
 +
If you don't want to put that port each time but redirect an external URL (if the app is a website hosted on your SME server) you need to:
 +
a) create that external domain on SME web interface for domain as '''www.your.externaldomain.tld'''
 +
 +
b) create a new variable (NodePort) to specify that port
 +
db domains setprop www.your.externadomain.tld NodePort 3003
 +
 +
c) use a custom fragment template file [b]/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts/27ProxyNodeJS[/b] with:
 +
 +
{
 +
    use esmith::DomainsDB;
 +
    my $domains = esmith::DomainsDB->open_ro;
 +
 +
    my $nodeport = $domains->get_prop($virtualHost, "NodePort") || "disabled";
 +
    return "    # skipping NodeJS redirect - no NodePort parameter\n" unless not $nodeport eq "disabled";
 +
 +
    $OUT .= "    # NodeJS port redirect\n" unless $nodeport eq 'disabled';
 +
    $OUT .= "    ProxyPreserveHost On\n" unless $nodeport eq 'disabled';
 +
    $OUT .= "    ProxyRequests Off\n" unless $nodeport eq 'disabled';
 +
    $OUT .= "    ProxyPass / http://localhost:$nodeport/\n" unless $nodeport eq 'disabled';
 +
    $OUT .= "    ProxyPassReverse / http://localhost:$nodeport/\n" unless $nodeport eq 'disabled';
 +
 +
}
 +
 +
Now just expand templates and restart
 +
expand-template /etc/httpd/conf/httpd.conf
 +
/etc/init.d/httpd-e-smith restart
 +
 +
That's all. It's working. ou can access you app extrnally using '''http://www.your.externaldomain.tld'''
 +
It's possible to access using SME with one LetsEncrypt certificate by directory/port
    
----
 
----
 
[[Category:Howto]]
 
[[Category:Howto]]
147

edits

Navigation menu