Line 65: |
Line 65: |
| yum --enablerepo=epel update nodejs c-ares19 http-parser libuv v8 | | yum --enablerepo=epel update nodejs c-ares19 http-parser libuv v8 |
| * NodeJS updates are released every 3 - 12 weeks; check for updates regularly. | | * NodeJS updates are released every 3 - 12 weeks; check for updates regularly. |
− | <headertabs/> | + | <headertabs /> |
| | | |
| | | |
Line 100: |
Line 100: |
| ==Test== | | ==Test== |
| node -v | | node -v |
| + | |
| + | |
| + | == Port Redirect for each application== |
| + | |
| + | {{Note box|| This is still work in progress and may not work correctly}} |
| + | |
| + | Each Node application you build must run on a different port. This can be configured in app.js |
| + | |
| + | If you want to redirect an external URL to the app port using a reverse proxy you can do the following |
| + | |
| + | 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 '''/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts/27ProxyNodeJS''' with: |
| + | <nowiki> |
| + | { |
| + | 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'; |
| + | } |
| + | </nowiki> |
| + | |
| + | Now just expand templates and restart |
| + | expand-template /etc/httpd/conf/httpd.conf |
| + | /etc/init.d/httpd-e-smith restart |
| + | |
| + | You should be able to access your app externally using '''http://www.your.externaldomain.tld''' |
| + | |
| + | It's possible to access using SME with one LetsEncrypt certificate by directory/port |
| | | |
| ---- | | ---- |
| [[Category:Howto]] | | [[Category:Howto]] |