From 25211d342e8ff85bff1dc8c39ffdf567e0885a4a Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Fri, 30 Apr 2021 12:36:28 -0400 Subject: [PATCH 01/15] Update cups.conf Reverse-proxy cups with nginx --- roles/cups/templates/cups.conf | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/roles/cups/templates/cups.conf b/roles/cups/templates/cups.conf index 8cf2b199f..af5fef5e3 100644 --- a/roles/cups/templates/cups.conf +++ b/roles/cups/templates/cups.conf @@ -1,2 +1,18 @@ -ProxyPass /cups http://localhost:631 -ProxyPassReverse /cups http://localhost:631 +location ~ /cups/(.*) { + proxy_pass https://127.0.0.1:631/$1; + + proxy_http_version 1.1; + proxy_set_header Accept-Encoding ""; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host '127.0.0.1'; + proxy_cache_bypass $http_upgrade; + + proxy_set_header X-Real-IP $remote_addr; + + sub_filter ' href="/' ' href="/cups/'; + sub_filter ' action="/' ' action="/cups/'; + sub_filter ' src="/' ' src="/cups/'; + sub_filter_types *; + sub_filter_once off; +} From 4d88529770c677ce61ddf561d878b546da6c8784 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Fri, 30 Apr 2021 13:32:42 -0400 Subject: [PATCH 02/15] Create nginx.yml --- roles/cups/tasks/nginx.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 roles/cups/tasks/nginx.yml diff --git a/roles/cups/tasks/nginx.yml b/roles/cups/tasks/nginx.yml new file mode 100644 index 000000000..f1fb802b1 --- /dev/null +++ b/roles/cups/tasks/nginx.yml @@ -0,0 +1,16 @@ +- name: Enable http://box/print via NGINX, by installing {{ nginx_conf_dir }}/cups.conf from template + template: + src: cups.conf + dest: "{{ nginx_conf_dir }}/cups.conf" # /etc/nginx/conf.d + when: cups_enabled + +- name: Disable http://box/print via NGINX, by removing {{ nginx_conf_dir }}/cups.conf + file: + path: "{{ nginx_conf_dir }}/cups.conf" # /etc/nginx/conf.d + state: absent + when: not cups_enabled + +- name: Restart 'nginx' systemd service + systemd: + name: nginx + state: restarted From 6e4984cdba15795542bff64d23ea626fe5479214 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Sat, 1 May 2021 18:38:18 -0400 Subject: [PATCH 03/15] Update cups.conf --- roles/cups/templates/cups.conf | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/roles/cups/templates/cups.conf b/roles/cups/templates/cups.conf index af5fef5e3..30cb7de11 100644 --- a/roles/cups/templates/cups.conf +++ b/roles/cups/templates/cups.conf @@ -1,18 +1,21 @@ -location ~ /cups/(.*) { - proxy_pass https://127.0.0.1:631/$1; +server { + listen 631; + location ~ /cups/(.*) { + proxy_pass http://127.0.0.1:631/$1; - proxy_http_version 1.1; - proxy_set_header Accept-Encoding ""; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_set_header Host '127.0.0.1'; - proxy_cache_bypass $http_upgrade; + proxy_http_version 1.1; + proxy_set_header Accept-Encoding ""; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host '127.0.0.1'; + proxy_cache_bypass $http_upgrade; - proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Real-IP $remote_addr; - sub_filter ' href="/' ' href="/cups/'; - sub_filter ' action="/' ' action="/cups/'; - sub_filter ' src="/' ' src="/cups/'; - sub_filter_types *; - sub_filter_once off; + sub_filter ' href="/' ' href="/cups/'; + sub_filter ' action="/' ' action="/cups/'; + sub_filter ' src="/' ' src="/cups/'; + sub_filter_types *; + sub_filter_once off; + } } From 73cea8a15c2a6fc26e7b7c0ca11d768fd985e69c Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Sat, 1 May 2021 18:39:20 -0400 Subject: [PATCH 04/15] Update cups.conf --- roles/cups/templates/cups.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/cups/templates/cups.conf b/roles/cups/templates/cups.conf index 30cb7de11..e72556e47 100644 --- a/roles/cups/templates/cups.conf +++ b/roles/cups/templates/cups.conf @@ -1,6 +1,6 @@ server { listen 631; - location ~ /cups/(.*) { + location /cups/(.*) { proxy_pass http://127.0.0.1:631/$1; proxy_http_version 1.1; From f343834206ee9d668d9cb0a111e33e14af9322db Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Sat, 1 May 2021 22:16:00 -0400 Subject: [PATCH 05/15] Update cups.conf --- roles/cups/templates/cups.conf | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/roles/cups/templates/cups.conf b/roles/cups/templates/cups.conf index e72556e47..2e76e1e2b 100644 --- a/roles/cups/templates/cups.conf +++ b/roles/cups/templates/cups.conf @@ -1,21 +1,18 @@ -server { - listen 631; - location /cups/(.*) { - proxy_pass http://127.0.0.1:631/$1; +location ~ /cups/(.*) { + proxy_pass http://127.0.0.1:631/$1; - proxy_http_version 1.1; - proxy_set_header Accept-Encoding ""; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_set_header Host '127.0.0.1'; - proxy_cache_bypass $http_upgrade; + proxy_http_version 1.1; + proxy_set_header Accept-Encoding ""; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host '127.0.0.1'; + proxy_cache_bypass $http_upgrade; - proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Real-IP $remote_addr; - sub_filter ' href="/' ' href="/cups/'; - sub_filter ' action="/' ' action="/cups/'; - sub_filter ' src="/' ' src="/cups/'; - sub_filter_types *; - sub_filter_once off; - } -} + sub_filter ' href="/' ' href="/cups/'; + sub_filter ' action="/' ' action="/cups/'; + sub_filter ' src="/' ' src="/cups/'; + sub_filter_types *; + sub_filter_once off; +} From 5f8514af7752e7333c750a9f96a3a44706276ac6 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Tue, 4 May 2021 10:55:27 -0400 Subject: [PATCH 06/15] Update cups.conf --- roles/cups/templates/cups.conf | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/roles/cups/templates/cups.conf b/roles/cups/templates/cups.conf index 2e76e1e2b..07e754ac7 100644 --- a/roles/cups/templates/cups.conf +++ b/roles/cups/templates/cups.conf @@ -1,18 +1,10 @@ -location ~ /cups/(.*) { +location ~ /print/(.*) { proxy_pass http://127.0.0.1:631/$1; - - proxy_http_version 1.1; - proxy_set_header Accept-Encoding ""; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; proxy_set_header Host '127.0.0.1'; - proxy_cache_bypass $http_upgrade; - - proxy_set_header X-Real-IP $remote_addr; - - sub_filter ' href="/' ' href="/cups/'; - sub_filter ' action="/' ' action="/cups/'; - sub_filter ' src="/' ' src="/cups/'; + + sub_filter ' href="/' ' href="/print/'; + sub_filter ' action="/' ' action="/print/'; + sub_filter ' src="/' ' src="/print/'; sub_filter_types *; sub_filter_once off; } From 374e0ad3ee611ea90ba497526e6f7ccb18f1f0f9 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Tue, 4 May 2021 11:09:32 -0400 Subject: [PATCH 07/15] Update nginx.yml --- roles/cups/tasks/nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/cups/tasks/nginx.yml b/roles/cups/tasks/nginx.yml index f1fb802b1..3c10ada76 100644 --- a/roles/cups/tasks/nginx.yml +++ b/roles/cups/tasks/nginx.yml @@ -1,6 +1,6 @@ - name: Enable http://box/print via NGINX, by installing {{ nginx_conf_dir }}/cups.conf from template template: - src: cups.conf + src: cups.conf.j2 dest: "{{ nginx_conf_dir }}/cups.conf" # /etc/nginx/conf.d when: cups_enabled From ba874673f67facf6997ce174f7d9e1c05f4bc410 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Tue, 4 May 2021 11:13:30 -0400 Subject: [PATCH 08/15] Rename cups.conf to cups.conf.j2 --- roles/cups/templates/{cups.conf => cups.conf.j2} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename roles/cups/templates/{cups.conf => cups.conf.j2} (100%) diff --git a/roles/cups/templates/cups.conf b/roles/cups/templates/cups.conf.j2 similarity index 100% rename from roles/cups/templates/cups.conf rename to roles/cups/templates/cups.conf.j2 From ae34a2009a67b61b70f9da6a67ad3baf89bd7d6a Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Tue, 4 May 2021 11:19:54 -0400 Subject: [PATCH 09/15] Update nginx.yml --- roles/cups/tasks/nginx.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/cups/tasks/nginx.yml b/roles/cups/tasks/nginx.yml index 3c10ada76..0e93f08ff 100644 --- a/roles/cups/tasks/nginx.yml +++ b/roles/cups/tasks/nginx.yml @@ -1,7 +1,7 @@ - name: Enable http://box/print via NGINX, by installing {{ nginx_conf_dir }}/cups.conf from template template: - src: cups.conf.j2 - dest: "{{ nginx_conf_dir }}/cups.conf" # /etc/nginx/conf.d + src: cups.conf + dest: /etc/nginx/conf.d/cups.conf when: cups_enabled - name: Disable http://box/print via NGINX, by removing {{ nginx_conf_dir }}/cups.conf From 974b221a87eed014c4bcca5368b56a21d7a3c4d3 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Tue, 4 May 2021 11:21:01 -0400 Subject: [PATCH 10/15] Update nginx.yml --- roles/cups/tasks/nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/cups/tasks/nginx.yml b/roles/cups/tasks/nginx.yml index 0e93f08ff..25ee45b8c 100644 --- a/roles/cups/tasks/nginx.yml +++ b/roles/cups/tasks/nginx.yml @@ -6,7 +6,7 @@ - name: Disable http://box/print via NGINX, by removing {{ nginx_conf_dir }}/cups.conf file: - path: "{{ nginx_conf_dir }}/cups.conf" # /etc/nginx/conf.d + path: /etc/nginx/conf.d/cups.conf state: absent when: not cups_enabled From 26d8c620fd04233e5f6e73c93d33933520ecbad1 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Tue, 4 May 2021 11:23:22 -0400 Subject: [PATCH 11/15] Rename cups.conf.j2 to cups.conf --- roles/cups/templates/{cups.conf.j2 => cups.conf} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename roles/cups/templates/{cups.conf.j2 => cups.conf} (100%) diff --git a/roles/cups/templates/cups.conf.j2 b/roles/cups/templates/cups.conf similarity index 100% rename from roles/cups/templates/cups.conf.j2 rename to roles/cups/templates/cups.conf From da1d147fc9cf4eec4cbdd10aa470f160705936d8 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Tue, 4 May 2021 11:51:20 -0400 Subject: [PATCH 12/15] Update to work with http://box/cups/ --- roles/cups/templates/cups.conf | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/roles/cups/templates/cups.conf b/roles/cups/templates/cups.conf index 07e754ac7..bd8d04c7f 100644 --- a/roles/cups/templates/cups.conf +++ b/roles/cups/templates/cups.conf @@ -7,4 +7,15 @@ location ~ /print/(.*) { sub_filter ' src="/' ' src="/print/'; sub_filter_types *; sub_filter_once off; +} + +location ~ /cups/(.*) { + proxy_pass http://127.0.0.1:631/$1; + proxy_set_header Host '127.0.0.1'; + + sub_filter ' href="/' ' href="/cups/'; + sub_filter ' action="/' ' action="/cups/'; + sub_filter ' src="/' ' src="/cups/'; + sub_filter_types *; + sub_filter_once off; } From 4141991a0b77394d558fbc1c5a6984895b8a28ee Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Tue, 4 May 2021 16:32:26 -0400 Subject: [PATCH 13/15] Update cups.conf --- roles/cups/templates/cups.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/roles/cups/templates/cups.conf b/roles/cups/templates/cups.conf index bd8d04c7f..1f286da4c 100644 --- a/roles/cups/templates/cups.conf +++ b/roles/cups/templates/cups.conf @@ -1,6 +1,8 @@ location ~ /print/(.*) { proxy_pass http://127.0.0.1:631/$1; proxy_set_header Host '127.0.0.1'; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Real-IP $remote_addr; sub_filter ' href="/' ' href="/print/'; sub_filter ' action="/' ' action="/print/'; @@ -12,6 +14,8 @@ location ~ /print/(.*) { location ~ /cups/(.*) { proxy_pass http://127.0.0.1:631/$1; proxy_set_header Host '127.0.0.1'; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Real-IP $remote_addr; sub_filter ' href="/' ' href="/cups/'; sub_filter ' action="/' ' action="/cups/'; From f45856eb3124f982cb44e5b5a9c6fcba03917efe Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Mon, 10 May 2021 15:31:36 -0400 Subject: [PATCH 14/15] Update cupsd.conf --- roles/cups/templates/cupsd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/cups/templates/cupsd.conf b/roles/cups/templates/cupsd.conf index 92a395cb8..b7f84ab42 100644 --- a/roles/cups/templates/cupsd.conf +++ b/roles/cups/templates/cupsd.conf @@ -1,7 +1,7 @@ ServerAlias * LogLevel warn MaxLogSize 1m -Listen {{ lan_ip }}:631 +#Listen {{ lan_ip }}:631 Listen localhost:631 Listen /var/run/cups/cups.sock Browsing On From 7c9f72fd1a34309bd7c603802c76cd7d5de3260a Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR <16546989+deldesir@users.noreply.github.com> Date: Mon, 10 May 2021 15:47:23 -0400 Subject: [PATCH 15/15] Update cupsd.conf --- roles/cups/templates/cupsd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/cups/templates/cupsd.conf b/roles/cups/templates/cupsd.conf index b7f84ab42..254f7d4a8 100644 --- a/roles/cups/templates/cupsd.conf +++ b/roles/cups/templates/cupsd.conf @@ -2,7 +2,7 @@ ServerAlias * LogLevel warn MaxLogSize 1m #Listen {{ lan_ip }}:631 -Listen localhost:631 +Listen 127.0.0.1:631 Listen /var/run/cups/cups.sock Browsing On BrowseLocalProtocols dnssd