1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

Explicit set the hostname

This commit is contained in:
Dennis Günnewig 2015-05-07 09:21:11 +02:00
parent 588f42f1df
commit 9741c68d34
3 changed files with 11 additions and 1 deletions

View file

@ -71,6 +71,10 @@ module Middleman
# @return [Fixnum] # @return [Fixnum]
config.define_setting :port, 4567, 'The preview server port' config.define_setting :port, 4567, 'The preview server port'
# Which server name should be used
# @return [NilClass, String]
config.define_setting :host, nil , 'The preview host name'
# Whether to serve the preview server over HTTPS. # Whether to serve the preview server over HTTPS.
# @return [Boolean] # @return [Boolean]
config.define_setting :https, false, 'Serve the preview server over SSL/TLS' config.define_setting :https, false, 'Serve the preview server over SSL/TLS'

View file

@ -14,6 +14,9 @@ module Middleman::Cli
method_option :port, method_option :port,
aliases: '-p', aliases: '-p',
desc: 'The port Middleman will listen on' desc: 'The port Middleman will listen on'
method_option :host,
aliases: '-h',
desc: 'The host name Middleman will use'
method_option :https, method_option :https,
type: :boolean, type: :boolean,
desc: 'Serve the preview server over SSL/TLS' desc: 'Serve the preview server over SSL/TLS'
@ -66,6 +69,7 @@ module Middleman::Cli
params = { params = {
port: options['port'], port: options['port'],
https: options['https'], https: options['https'],
host: options['host'],
ssl_certificate: options['ssl_certificate'], ssl_certificate: options['ssl_certificate'],
ssl_private_key: options['ssl_private_key'], ssl_private_key: options['ssl_private_key'],
environment: options['environment'], environment: options['environment'],

View file

@ -112,12 +112,13 @@ module Middleman
config[:environment] = opts[:environment].to_sym if opts[:environment] config[:environment] = opts[:environment].to_sym if opts[:environment]
config[:port] = opts[:port] if opts[:port] config[:port] = opts[:port] if opts[:port]
config[:host] = opts[:host].presence || Socket.gethostname.tr(' ', '+')
config[:https] = opts[:https] unless opts[:https].nil? config[:https] = opts[:https] unless opts[:https].nil?
config[:ssl_certificate] = opts[:ssl_certificate] if opts[:ssl_certificate] config[:ssl_certificate] = opts[:ssl_certificate] if opts[:ssl_certificate]
config[:ssl_private_key] = opts[:ssl_private_key] if opts[:ssl_private_key] config[:ssl_private_key] = opts[:ssl_private_key] if opts[:ssl_private_key]
end end
@host = Socket.gethostname.tr(' ', '+') @host = @app.config[:host]
@port = @app.config[:port] @port = @app.config[:port]
@https = @app.config[:https] @https = @app.config[:https]
@ -182,6 +183,7 @@ module Middleman
http_opts = { http_opts = {
Port: port, Port: port,
AccessLog: [], AccessLog: [],
ServerName: host,
DoNotReverseLookup: true DoNotReverseLookup: true
} }