How to change chef nginx default http port 80?

2020-07-13 10:06发布

问题:

I tried to install apache on a machine that chef-server was installed. Apache could not start up due to the occupation of port 80 by chef nginx. If I want to let apache use port 80 as default, is it possible to change chef nginx default http port to another one?

I found a solution on the Internet to set virtual host on both apache and nginx, but they need a different FQDN as server name. My machine uses an IP instead of FQDN, so I need to change the default HTTP port for chef nginx.

I tried to add /etc/chef-server/chef-server.rb with the following content:

nginx['non_ssl_port'] = 9898

Then I ran 'chef-server-ctl reconfigure'. It didn't work.

Can anyone help on this? Thanks.

Updated

My information was wrong regarding changing the chef server settings.

The settings should be added into /etc/opscode/chef-server.rb for Chef12. After chef-server-ctl reconfigure, nginx's HTTP port is changed to 9898. Thanks.

回答1:

Here is how to change the port. Edit /etc/opscode/chef-server.rb

nginx['non_ssl_port'] = 10080
nginx['ssl_port'] = 10443
nginx['url'] = "https://<YOUR URL>:10443/"

and adjust your local ~/.chef/knife.rb to read

chef_server_url 'https://<YOUR URL>:10443/organizations/<YOUR ORG>'

But currently there is a bug in Chef that prevents the embedded nginx to run on a non standard port: https://github.com/chef/chef-server/issues/50



回答2:

The settings should be added into /etc/opscode/chef-server.rb for Chef12.

After chef-server-ctl reconfigure, nginx's HTTP port is changed to 9898.