Sails: How to run sails.js application on port 80 with example?

Created on 31 Jan 2014  路  24Comments  路  Source: balderdashy/sails

I want to run sails.js application ny default to 80 not 1337.

My local url must be like this http://localhost not http:localhost:1337

Most helpful comment

Set the port in config/local.js to 80, or specify env PRODUCTION and add the conditional. If you do this (run on port 80), you must either run sails as root, or forward a port higher than 1024 to port 80 (because ports under 1024 require root privilege).

Here's an example to use with iptables:

--iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
--iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
--iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

Update: Please ask this question on stackoverflow! We keep asking you to do that. At some point people will start ignoring you. So post this question on stackoverflow so it can be answered in dept there.

All 24 comments

Set the port in config/local.js to 80, or specify env PRODUCTION and add the conditional. If you do this (run on port 80), you must either run sails as root, or forward a port higher than 1024 to port 80 (because ports under 1024 require root privilege).

Here's an example to use with iptables:

--iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
--iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
--iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

Update: Please ask this question on stackoverflow! We keep asking you to do that. At some point people will start ignoring you. So post this question on stackoverflow so it can be answered in dept there.

i change like this below in local.js

/**

  • Local environment settings
    *
  • While you're developing your app, this config file should include
  • any settings specifically for your development computer (db passwords, etc.)
  • When you're ready to deploy your app in production, you can use this file
  • for configuration options on the server where it will be deployed.
    *
    *
  • PLEASE NOTE:
  • This file is included in your .gitignore, so if you're using git
  • as a version control solution for your Sails app, keep in mind that
  • this file won't be committed to your repository!
    *
  • Good news is, that means you can specify configuration for your local
  • machine in this file without inadvertently committing personal information
  • (like database passwords) to the repo. Plus, this prevents other members
  • of your team from commiting their local configuration changes on top of yours.
    *
    *
  • For more information, check out:
  • http://sailsjs.org/#documentation
    */

module.exports = {

// The port setting determines which TCP port your app will be deployed on
// Ports are a transport-layer concept designed to allow many different
// networking applications run at the same time on a single computer.
// More about ports: http://en.wikipedia.org/wiki/Port_(computer_networking)
//
// By default, if it's set, Sails uses the PORT environment variable.
// Otherwise it falls back to port 1337.
//
// In production, you'll probably want to change this setting
// to 80 (http://) or 443 (https://) if you have an SSL certificate

port: process.env.PORT || 80,

// The runtime "environment" of your Sails app is either 'development' or 'production'.
//
// In development, your Sails app will go out of its way to help you
// (for instance you will receive more descriptive error and debugging output)
//
// In production, Sails configures itself (and its dependencies) to optimize performance.
// You should always put your app in production mode before you deploy it to a server-
// This helps ensure that your Sails app remains stable, performant, and scalable.
//
// By default, Sails sets its environment using the NODE_ENV environment variable.
// If NODE_ENV is not set, Sails will run in the 'development' environment.

environment: process.env.NODE_ENV || 'PRODUCTION'

};

but still http://localhost not working

it gives blank page

http://localhost:80 also not working

Read my previous answer.

http://localhost:8080/ like this working but http://localhost not working

Read my first answer.

Do u have full source code..

Just chiming in here as @rRWOverdijk already said it, just didn't give a command .. node can't lift sails on lower level ports without a sudo infront of it.. sudo sails lift

sudo sails lift

this command not working for centos ....

http://localhost:8080/ like this working but http://localhost not working

Someone from Balderdash... please... stop the insanity... block this user... @jigneshnavsoft

https://help.github.com/articles/blocking-a-user

pl. dont do this. I will take care men..

Yes i got the result ...thanks a lot men

@mogga I didn't even know that was possible (otherwise I'd have suggested it myself). Thanks! :)

Thanks men

Thanks men

thanks men

He will take care, men.

funny post, men :)
pl. dont do this. I will take care men..

Yeah, and yes, thanks man. D ! :) Take Care ! :D

oh god men, so many email alerts, men. unsubscribe, men.

thanks ..am in love with sails

I want to run sails.js application ny default to 80 not 1337.

My local url must be like this http://localhost not http:localhost:1337

Run with port as an option
sails console --port 1338

try this open config/env/production.js and scroll down, find //port 80 end then, uncomment it , work well for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3imed-jaberi picture 3imed-jaberi  路  3Comments

Salakar picture Salakar  路  4Comments

victory-deployment picture victory-deployment  路  4Comments

pawankorotane picture pawankorotane  路  3Comments

Alirezamohammadi picture Alirezamohammadi  路  4Comments