Skip to content

Commit

Permalink
Merge pull request #345 from gilbitron/20210205-ip-address
Browse files Browse the repository at this point in the history
New: Defaulting listening IP address and adding override
  • Loading branch information
ryanlelek authored Mar 28, 2021
2 parents f83cc2d + d5872a3 commit c32674e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function initialize (config) {
var app = express();
var router = express.Router();

// Setup Port
// Set IP Address and Port
app.set('host', process.env.HOST || '127.0.0.1');
app.set('port', process.env.PORT || 3000);

// set locale as date and time format
Expand Down
14 changes: 13 additions & 1 deletion example/content/install/production-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,17 @@ Instead it is preferred to use a reverse proxy for security reasons.
Heroku and other services handle this aspect for you, but you can implement your own reverse proxy with Nginx or Apache.
**See [Related Projects](%base_url%/related-projects) for deployment scripts to use on your own servers**

You can change the port anytime by setting the environment variable in your shell's profile, or running in-line as below:
## Listening Port
You can change the listening port anytime by setting the environment variable in your shell's profile, or running in-line as below:
`$ PORT=1234 npm start`

## Listening Host Address / IP

### Defaults
Raneto listens only to localhost (`127.0.0.1`) traffic by default now (v0.17.0).
This is to prevent unintended exposure and access of your documentation from older versions.
Previous versions before v0.17.0 would bind to all IP addresses, which could accidentally make documents available on the public internet.

### Override
To override the default IP host, please look above at an Nginx reverse proxy to access `127.0.0.1` or you can manually set the IP Host (private or public) setting the Environment Variable `HOST` somewhere.
`$ HOST=192.168.0.10 npm start`
6 changes: 4 additions & 2 deletions example/multiple-instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ mainApp.use('/en', appEn);
mainApp.use('/es', appEs);

// Load the HTTP Server
const server = mainApp.listen(3000, function () {
const server = mainApp.listen(appEn.get('port'), appEn.get('host'), function () {
debug('Express HTTP server listening on port ' + server.address().port);
});

// Now navigate to http://localhost:3000/en and http://localhost:3000/es
// Now you can navigate to both:
// - http://localhost:3000/en
// - http://localhost:3000/es
2 changes: 1 addition & 1 deletion example/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ var config = require('./config.default.js');
var app = raneto(config);

// Load the HTTP Server
var server = app.listen(app.get('port'), function () {
var server = app.listen(app.get('port'), app.get('host'), function () {
debug('Express HTTP server listening on port ' + server.address().port);
});

0 comments on commit c32674e

Please sign in to comment.