{"id":3817,"date":"2016-04-19T12:39:33","date_gmt":"2016-04-19T12:39:33","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3817"},"modified":"2016-04-19T12:39:33","modified_gmt":"2016-04-19T12:39:33","slug":"operationalizing-node-app-webpack-forever","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/","title":{"rendered":"Operationalizing a Node app: Webpack to Forever"},"content":{"rendered":"<p>When you set up your node application, you likely need to run the bundling of Javascript files as part of the release process. <\/p>\n<pre lang=\"javascript\">\nwebpack\nmv bundle.js public\/search\/\n<\/pre>\n<p>The most fiddly bit of this is getting paths correct.<\/p>\n<p>When I deployed my application, I put it at &#8220;\/search\/ssl_search&#8221;, so it could hang off this domain. This means that the application lives in a folder named &#8220;ssl_search&#8221; on the file system, but the &#8220;public&#8221; folder in Express.js needs to replicate the folder structure &#8220;\/search&#8221; to be able to serve files correctly.<\/p>\n<p>To get this to work, you need to set up apache to forward ports for these paths:<\/p>\n<pre lang=\"xml\">\nLoadModule proxy_module modules\/mod_proxy.so\nLoadModule proxy_http_module modules\/mod_proxy_http.so\n\n<VirtualHost 173.255.224.150:80>\n      ServerAdmin gary.sieling@gmail.com\n      ServerName garysieling.com\n      ServerAlias www.garysieling.com\n      DocumentRoot \/srv\/www\/garysieling.com\/public_html\/\n      ErrorLog \/var\/log\/apache2\/garysieling-error.log\n      CustomLog \/var\/log\/apache2\/garysieling-access.log combined\n\n      ProxyRequests Off\n      ProxyErrorOverride Off\n\n      <Location \"\/search\">\n        ProxyPass \"http:\/\/127.0.0.1:3000\/search\"\n      <\/Location>\n\n      ProxyPassReverse \"\/search\" \"http:\/\/localhost:3000\/search\"\n<\/VirtualHost>\n<\/pre>\n<p>If you screw this up (ProxyRequests On) you will turn your server into an open relay proxy for people (forward proxy), which is not a great idea (you want a reverse proxy).<\/p>\n<p>You may need to enable the proxy modules:<\/p>\n<pre lang=\"bash\">\na2enmod proxy\na2enmod proxy_http\n<\/pre>\n<p>I saw some documentation which recommended a hard stop of apache, to get these to really take (not sure how necessary this is):<\/p>\n<pre lang=\"bash\">\n\/etc\/init.d\/apache2 stop && \/etc\/init.d\/apache2 start\n<\/pre>\n<p>You can use &#8220;Forever&#8221; to keep a node application running:<\/p>\n<pre lang=\"javascript\">\nnpm install forever --save\nnode_modules\/forever\/bin\/forever start \\\n -append \\\n --spinSleepTime 100 \\\n --minUptime 200 \\\n -l \/var\/log\/ssl-search-forever.log \\\n -o \/var\/log\/ssl-search-output.log \\\n -e \/var\/log\/ssl-search-error.log \\\n index.js\n\nnode_modules\/forever\/bin\/forever list\n<\/pre>\n<p>There are a few caveats with logging &#8211; to get the right access log format, you need something like this:<\/p>\n<pre lang=\"javascript\">\napp.use(require(\"morgan\")(\"combined\"));\n<\/pre>\n<p>There are a couple ways to handle log rotation &#8211; it looks like you can use features built into morgan, or you can use general purpose logrotate.d which is what I did:<\/p>\n<pre>\n\/var\/log\/ssl-search*.log {\n  daily\n  dateext\n  missingok\n  rotate 7\n  compress\n  delaycompress\n  notifempty\n  copytruncate\n}\n<\/pre>\n<p><b>CDN<\/b><br \/>\nIf you&#8217;re using a CDN (e.g. Cloudflare) there are a few things to note as well:<\/p>\n<p>When you&#8217;re working on this, you&#8217;ll need to remember to disable caching.<\/p>\n<p>Cloudflare can add SSL in front for you, so if you have hard-coded URLs in your app, you should probably remove them to make your life simpler.<\/p>\n<p>Cloudflare has an interesting set of caching options:<br \/>\n<img alt='' class='alignnone size-full wp-image-3835' src='http:\/\/172.104.26.128\/wp-content\/uploads\/2016\/04\/img_57162851b55e6.png' \/><\/p>\n<p>If you want it to cache the most aggressively, you can have it cache every page. Depending on what you&#8217;re trying to do, you may want to design the application to avoid query strings (?x=12345) for different pages, to make this simpler.<\/p>\n<p><b>SEO<\/b><br \/>\nYou may also want to make a <a href=\"https:\/\/www.garysieling.com\/blog\/creating-sitemap-express-js-solr-database\">sitemap in your node app<\/a> and register it with Google Webmaster Tools \/ Bing Webmaster Tools.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>All the things I had to do to get my node app running<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[12],"tags":[49,236,302,345,387,388,389,592],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"All the things I had to do to get my node app running\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"gary\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Gary Sieling - Software Engineer\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Operationalizing a Node app: Webpack to Forever - Gary Sieling\" \/>\n\t\t<meta property=\"og:description\" content=\"All the things I had to do to get my node app running\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2016-04-19T12:39:33+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2016-04-19T12:39:33+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Operationalizing a Node app: Webpack to Forever - Gary Sieling\" \/>\n\t\t<meta name=\"twitter:description\" content=\"All the things I had to do to get my node app running\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/operationalizing-node-app-webpack-forever\\\/#blogposting\",\"name\":\"Operationalizing a Node app: Webpack to Forever - Gary Sieling\",\"headline\":\"Operationalizing a Node app: Webpack to Forever\",\"author\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#organization\"},\"datePublished\":\"2016-04-19T12:39:33+00:00\",\"dateModified\":\"2016-04-19T12:39:33+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/operationalizing-node-app-webpack-forever\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/operationalizing-node-app-webpack-forever\\\/#webpage\"},\"articleSection\":\"How-To, apache, forever, javascript, logging, node, node.js, nodejs, webpack\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/operationalizing-node-app-webpack-forever\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.garysieling.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/how-to\\\/#listItem\",\"name\":\"How-To\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/how-to\\\/#listItem\",\"position\":2,\"name\":\"How-To\",\"item\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/how-to\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/operationalizing-node-app-webpack-forever\\\/#listItem\",\"name\":\"Operationalizing a Node app: Webpack to Forever\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/operationalizing-node-app-webpack-forever\\\/#listItem\",\"position\":3,\"name\":\"Operationalizing a Node app: Webpack to Forever\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/how-to\\\/#listItem\",\"name\":\"How-To\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#organization\",\"name\":\"Gary Sieling\",\"description\":\"Software Engineer\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/\",\"name\":\"gary\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/operationalizing-node-app-webpack-forever\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0be925276d848ffe98a6a9dc8cf33e67?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"gary\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/operationalizing-node-app-webpack-forever\\\/#webpage\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/operationalizing-node-app-webpack-forever\\\/\",\"name\":\"Operationalizing a Node app: Webpack to Forever - Gary Sieling\",\"description\":\"All the things I had to do to get my node app running\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/operationalizing-node-app-webpack-forever\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\"},\"datePublished\":\"2016-04-19T12:39:33+00:00\",\"dateModified\":\"2016-04-19T12:39:33+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/\",\"name\":\"Gary Sieling\",\"description\":\"Software Engineer\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Operationalizing a Node app: Webpack to Forever - Gary Sieling","description":"All the things I had to do to get my node app running","canonical_url":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/#blogposting","name":"Operationalizing a Node app: Webpack to Forever - Gary Sieling","headline":"Operationalizing a Node app: Webpack to Forever","author":{"@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author"},"publisher":{"@id":"https:\/\/www.garysieling.com\/blog\/#organization"},"datePublished":"2016-04-19T12:39:33+00:00","dateModified":"2016-04-19T12:39:33+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/#webpage"},"isPartOf":{"@id":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/#webpage"},"articleSection":"How-To, apache, forever, javascript, logging, node, node.js, nodejs, webpack"},{"@type":"BreadcrumbList","@id":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.garysieling.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/category\/how-to\/#listItem","name":"How-To"}},{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/category\/how-to\/#listItem","position":2,"name":"How-To","item":"https:\/\/www.garysieling.com\/blog\/category\/how-to\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/#listItem","name":"Operationalizing a Node app: Webpack to Forever"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/#listItem","position":3,"name":"Operationalizing a Node app: Webpack to Forever","previousItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/category\/how-to\/#listItem","name":"How-To"}}]},{"@type":"Organization","@id":"https:\/\/www.garysieling.com\/blog\/#organization","name":"Gary Sieling","description":"Software Engineer","url":"https:\/\/www.garysieling.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author","url":"https:\/\/www.garysieling.com\/blog\/author\/gary\/","name":"gary","image":{"@type":"ImageObject","@id":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/0be925276d848ffe98a6a9dc8cf33e67?s=96&d=identicon&r=g","width":96,"height":96,"caption":"gary"}},{"@type":"WebPage","@id":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/#webpage","url":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/","name":"Operationalizing a Node app: Webpack to Forever - Gary Sieling","description":"All the things I had to do to get my node app running","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.garysieling.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/#breadcrumblist"},"author":{"@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author"},"creator":{"@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author"},"datePublished":"2016-04-19T12:39:33+00:00","dateModified":"2016-04-19T12:39:33+00:00"},{"@type":"WebSite","@id":"https:\/\/www.garysieling.com\/blog\/#website","url":"https:\/\/www.garysieling.com\/blog\/","name":"Gary Sieling","description":"Software Engineer","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.garysieling.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Gary Sieling - Software Engineer","og:type":"article","og:title":"Operationalizing a Node app: Webpack to Forever - Gary Sieling","og:description":"All the things I had to do to get my node app running","og:url":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/","article:published_time":"2016-04-19T12:39:33+00:00","article:modified_time":"2016-04-19T12:39:33+00:00","twitter:card":"summary_large_image","twitter:title":"Operationalizing a Node app: Webpack to Forever - Gary Sieling","twitter:description":"All the things I had to do to get my node app running"},"aioseo_meta_data":{"post_id":"3817","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2023-02-04 16:49:56","updated":"2026-07-06 01:48:48","ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.garysieling.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.garysieling.com\/blog\/category\/how-to\/\" title=\"How-To\">How-To<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tOperationalizing a Node app: Webpack to Forever\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.garysieling.com\/blog"},{"label":"How-To","link":"https:\/\/www.garysieling.com\/blog\/category\/how-to\/"},{"label":"Operationalizing a Node app: Webpack to Forever","link":"https:\/\/www.garysieling.com\/blog\/operationalizing-node-app-webpack-forever\/"}],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3817"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3817"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3817\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}