Skip to content

Commit

Permalink
Adaptations to work on RHEL9 (#6)
Browse files Browse the repository at this point in the history
* RHEL9 First version
  • Loading branch information
manegron authored Oct 27, 2023
1 parent a2a7f42 commit 3f80682
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cookbook to install and configure redborder nginx cookbook

### Platforms

- Centos 7
- Rocky Linux 9

### Chef

Expand Down
29 changes: 23 additions & 6 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
begin
user = new_resource.user

yum_package "nginx" do
dnf_package "nginx" do
action :upgrade
flush_cache [:before]
end

user user do
action :create
system true
execute "create_user" do
command "/usr/sbin/useradd -r nginx"
ignore_failure true
not_if "getent passwd nginx"
end

%w[ /var/www /var/www/cache /var/log/nginx /etc/nginx/ssl /etc/nginx/conf.d ].each do |path|
Expand Down Expand Up @@ -105,6 +106,14 @@
variables(:erchef_port => erchef_port)
notifies :restart, "service[nginx]"
end

service "nginx" do
service_name "nginx"
ignore_failure true
supports :status => true, :reload => true, :restart => true, :enable => true
action [:nothing]
end

rescue => e
Chef::Log.error(e.message)
end
Expand All @@ -123,6 +132,14 @@
variables(:s3_port => s3_port)
notifies :restart, "service[nginx]"
end

service "nginx" do
service_name "nginx"
ignore_failure true
supports :status => true, :reload => true, :restart => true, :enable => true
action [:nothing]
end

rescue => e
Chef::Log.error(e.message)
end
Expand Down Expand Up @@ -162,7 +179,7 @@
action :nothing
end.run_action(:run)

node.set["nginx"]["registered"] = true
node.normal["nginx"]["registered"] = true
Chef::Log.info("Nginx service has been registered to consul")
end
rescue => e
Expand All @@ -179,7 +196,7 @@
action :nothing
end.run_action(:run)

node.set["nginx"]["registered"] = false
node.normal["nginx"]["registered"] = false
Chef::Log.info("Nginx service has been deregistered from consul")
end
rescue => e
Expand Down
2 changes: 1 addition & 1 deletion resources/recipes/configure_solo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

nginx_config "config" do
service_name "s3"
action [:add, :add_s3, :configure_certs]
action [:add, :configure_certs, :add_s3]
end
14 changes: 12 additions & 2 deletions resources/templates/default/s3.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

upstream s3 {
server localhost:<%= @s3_port %> weight=2 max_fails=3 fail_timeout=5s;
}
}

map $http_host $port_in_host {
~:(\d+)$ $1;
default "";
}

server {
listen 443 ssl http2;
Expand All @@ -22,7 +27,12 @@ server {

client_max_body_size 512m;

proxy_set_header Host $host;
set $modified_host $host;
if ($port_in_host) {
set $modified_host $host:$server_port;
}
proxy_set_header Host $modified_host;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
Expand Down

0 comments on commit 3f80682

Please sign in to comment.