Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to listen host Loopback #2160

Open
xxz199539 opened this issue Feb 27, 2024 · 1 comment
Open

how to listen host Loopback #2160

xxz199539 opened this issue Feb 27, 2024 · 1 comment

Comments

@xxz199539
Copy link

xxz199539 commented Feb 27, 2024

Hi, i want to listen ::1 and localhost in my rack server. my code:

def self.run_service(ser_proc_name, ser_cls_name, service_file, port)
	pid = fork do
		dir, file = File.dirname(service_file), File.basename(service_file)
		Dir.chdir(dir)
		load file
		$0 = ser_proc_name
            ssl_options = {
                :private_key_file => nil,
                :cert_chain_file => nil,
                :verify_peer => false,
            }
	    rack_handler_config = {
		:server => 'thin',
		:Host => '::1', 
		:Port => port
	    }
	    ser_cls_name = ser_cls_name.downcase.include?("web") ? ser_cls_name : ser_cls_name + "Service"
	    Rack::Handler::Thin.run(DDI.const_get(ser_cls_name), rack_handler_config) do |server|
                  server.ssl = true
                  server.ssl_options = ssl_options
	    end
	end
	Process.detach(pid)
end

but it not work for localhost, i got error when execute commad 'telnet localhost 20121'. so how can i config the 'Host' to listen 'localhost' and '::1' at the same time?
thanks.

@xxz199539
Copy link
Author

xxz199539 commented Feb 27, 2024

when i set

rack_handler_config = {
		:server => 'thin',
		:Host => '::', 
		:Port => port
	    }

i can get response by 'telnet :: 20121' and 'telnet 0.0.0.0 2012'.so has the same way to support '::1' and 'localhost'(Loopback address)?

@xxz199539 xxz199539 changed the title how to listen host include localhost and ::1? how to listen host Loopback Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant