OPNsense Forum

Archive => 22.1 Legacy Series => Topic started by: muchacha_grande on June 23, 2022, 06:12:43 pm

Title: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: muchacha_grande on June 23, 2022, 06:12:43 pm
Hi, I have this problem after update. I read that NGINX plugin was updated two.

The error I see in NGINX log is: unknown directive "js_include" in /usr/local/etc/nginx/nginx.conf:41

How can I revert back to the previous NGINX version?

Thank you

EDIT: this was solved on hotfix 22.1.9_1

Thank you again
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 23, 2022, 06:36:26 pm
I have the same problem:
unknown directive "js_include" in /usr/local/etc/nginx/nginx.conf:176

How can we fix this?
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 23, 2022, 06:36:44 pm
deleted
Title: Re: NGINX does'n start after update to 22.1.9
Post by: muchacha_grande on June 23, 2022, 06:47:23 pm
I fixed it reverting nginx to the previous version.
So, the first thing I tried is 'opnsense-revert -r 22.1.8 os-nginx' and it didn't work. Then I tried 'opnsense-revert -r 22.1.8 nginx' and it worked.
So I think that the problem is on this update 'nginx upgraded: 1.20.2_9,2 -> 1.22.0_5,2'.
Looking back in the nginx log I found that the error started to happen in the exact time the nginx package was updated.

May be os-nginx package can be updated preserving the previous nginx package.

I'll try

EDIT: I'm trying os-nginx 1.28 with nginx 1.20.2_9,2 and for now it is working fine. I will pin to this nginx version.
Title: Re: NGINX does'n start after update to 22.1.9
Post by: peter.vynck on June 23, 2022, 06:51:44 pm
Same issue with nginx here. Same error.
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 23, 2022, 06:59:24 pm
Thnx!
this
Quote
opnsense-revert -r 22.1.8 nginx'
fixed it for me also.
W'll wait for the fix for updating nginx again.
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 23, 2022, 07:09:05 pm
Ok.. did something fun...
I updated (only) the nginx again to the latest version, and now it keeps working?!

don't know what caused it, hope it works at your end also?

NB. I tested further with stopping nxginx and starting it again, than it is broken again. so reverted back to opnsense-revert -r 22.1.8 nginx'
Title: Re: NGINX does'n start after update to 22.1.9
Post by: PIv0 on June 23, 2022, 07:10:15 pm
I have the same problem:
unknown directive "js_include" in /usr/local/etc/nginx/nginx.conf:176

How can we fix this?

I have the same problem.

The documentation for module ngx_http_js_module says:
The directive (js_include) was made obsolete in version 0.4.0 and was removed in version 0.7.1. The js_import directive should be used instead.

A simple substitution leads to other errors.
I will wait for this error to be fixed. I hope we don't have to wait.
Title: Re: NGINX does'n start after update to 22.1.9
Post by: franco on June 23, 2022, 09:04:07 pm
Reverting nginx is the easiest solution for the time being. The plugin wasn't changed in that are, which is good and bad at the same time in this particular case.


Cheers,
Franco
Title: Re: NGINX does'n start after update to 22.1.9
Post by: mvdheijkant on June 24, 2022, 10:22:31 am
From which page can I revert separately Nginx or it it done through the console?
Title: Re: NGINX does'n start after update to 22.1.9
Post by: franco on June 24, 2022, 10:30:44 am
Console only.


Cheers,
Franco
Title: Re: NGINX does'n start after update to 22.1.9
Post by: PIv0 on June 24, 2022, 11:15:49 am
From which page can I revert separately Nginx or it it done through the console?

I did like this:
# opnsense-revert -r 22.1.8 nginx
Title: Re: NGINX does'n start after update to 22.1.9
Post by: Fright on June 24, 2022, 12:21:30 pm
I think that may be due to the removal of support for the js_include directive.
should use js_import now.
http://nginx.org/en/docs/http/ngx_http_js_module.html#js_import

https://github.com/opnsense/plugins/pull/3016 worked on test vm
Title: Re: NGINX does'n start after update to 22.1.9
Post by: muchacha_grande on June 24, 2022, 08:23:51 pm
Great!! I confirm the fix is working fine.
Title: Re: NGINX does'n start after update to 22.1.9
Post by: XeroX on June 25, 2022, 07:25:10 pm
Can confirm patch works.

Code: [Select]
opnsense-patch -c plugins a357676
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 25, 2022, 08:44:43 pm
Tried the patch also, but it does not work.
When i Stop Nginx and try to restart it, it fails.

Quote
# opnsense-patch -c plugins a357676
Fetched a357676 via https://github.com/opnsense/plugins
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|From a357676b926ba9db66bd72c246e9e78bbfaebfaa Mon Sep 17 00:00:00 2001
|From: kulikov-a <36099472+kulikov-a@users.noreply.github.com>
|Date: Sat, 25 Jun 2022 11:42:14 +0300
|Subject: [PATCH] njs0.7.1 compat. (#3016)
|
|---
| www/nginx/src/opnsense/scripts/nginx/ngx_functions.js         | 2 ++
| .../src/opnsense/service/templates/OPNsense/Nginx/http.conf   | 4 ++--
| 2 files changed, 4 insertions(+), 2 deletions(-)
|
|diff --git a/www/nginx/src/opnsense/scripts/nginx/ngx_functions.js b/www/nginx/src/opnsense/scripts/nginx/ngx_functions.js
|index 5f17d76ee9..3acd7d9dbc 100755
|--- a/www/nginx/src/opnsense/scripts/nginx/ngx_functions.js
|+++ b/www/nginx/src/opnsense/scripts/nginx/ngx_functions.js
--------------------------
Patching file opnsense/scripts/nginx/ngx_functions.js using Plan A...
Hunk #1 succeeded at 47.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf b/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf
|index 13e5659a99..735bab34d2 100644
|--- a/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf
|+++ b/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf
--------------------------
Patching file opnsense/service/templates/OPNsense/Nginx/http.conf using Plan A...
Hunk #1 succeeded at 21.
done
All patches have been applied successfully.  Have a nice day.
patch did run

@XeroX, did you try to stop and restart Nginx after the patch?

NB reverted back to "opnsense-revert -r 22.1.8 os-nginx -> still my nginx is broken and wont start anymore. trying to update it to the latest version again


Title: Re: NGINX does'n start after update to 22.1.9
Post by: XeroX on June 25, 2022, 08:47:44 pm
@XeroX, did you try to stop and restart Nginx after the patch?

Nginx was in stopped state while patching and started afterwards.

What does general logs say?
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 25, 2022, 08:51:49 pm
reverting back and upgrading and patching all keeps my nginx broken....

i have unknown directive "js_include" in /usr/local/etc/nginx/nginx.conf:176
Title: Re: NGINX does'n start after update to 22.1.9
Post by: XeroX on June 25, 2022, 09:00:36 pm
Looks like completely messed up.

Upgrade to latest and apply patch afterwards. Applying patch twice will undo the patch.
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 25, 2022, 09:19:27 pm
ok,
did
1. opnsense-revert -r 22.1.8 os-nginx (again now)
2. upgraded nginx to v 1.28 from the opnsense gui
3. run the patch from terminal: opnsense-patch -c plugins a357676

Quote
opnsense-patch -c plugins a357676
Found local copy of a357676, skipping fetch.
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|From a357676b926ba9db66bd72c246e9e78bbfaebfaa Mon Sep 17 00:00:00 2001
|From: kulikov-a <36099472+kulikov-a@users.noreply.github.com>
|Date: Sat, 25 Jun 2022 11:42:14 +0300
|Subject: [PATCH] njs0.7.1 compat. (#3016)
|
|---
| www/nginx/src/opnsense/scripts/nginx/ngx_functions.js         | 2 ++
| .../src/opnsense/service/templates/OPNsense/Nginx/http.conf   | 4 ++--
| 2 files changed, 4 insertions(+), 2 deletions(-)
|
|diff --git a/www/nginx/src/opnsense/scripts/nginx/ngx_functions.js b/www/nginx/src/opnsense/scripts/nginx/ngx_functions.js
|index 5f17d76ee9..3acd7d9dbc 100755
|--- a/www/nginx/src/opnsense/scripts/nginx/ngx_functions.js
|+++ b/www/nginx/src/opnsense/scripts/nginx/ngx_functions.js
--------------------------
Patching file opnsense/scripts/nginx/ngx_functions.js using Plan A...
Hunk #1 succeeded at 47.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf b/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf
|index 13e5659a99..735bab34d2 100644
|--- a/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf
|+++ b/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/http.conf
--------------------------
Patching file opnsense/service/templates/OPNsense/Nginx/http.conf using Plan A...
Hunk #1 succeeded at 21.
done
All patches have been applied successfully.  Have a nice day.

did reboot my opnsense box after the patch (did not try to start nginx)

and that fixed it! all is working, did not try to stop and start nginx again now... to glad it is working :-)

XeroX: have you tried stop and start nginx from the opnsense gui?
Title: Re: NGINX does'n start after update to 22.1.9
Post by: XeroX on June 25, 2022, 09:41:41 pm
XeroX: have you tried stop and start nginx from the opnsense gui?

Yes, works fine for me.
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 25, 2022, 09:43:01 pm
Ok, thanks for testing. I will check it out later also.
Title: Re: NGINX does'n start after update to 22.1.9
Post by: ThyOnlySandman on June 25, 2022, 11:29:43 pm
Same - unknown directive "js_include" in /usr/local/etc/nginx/nginx.conf:118

Tried suggestion twice now.  Still not starting.

1. opnsense-revert -r 22.1.8 os-nginx (again now)
2. upgraded nginx to v 1.28 from the opnsense gui
3. run the patch from terminal: opnsense-patch -c plugins a357676
4.  reboot

Also tried starting with nginx 1.27 - also won't start.  :( 
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 26, 2022, 08:16:34 am
Was nginx stopped before those steps?
That was the difference from my earlier testing. And can confirm it is working now, just like XeroX.
hope it will work at your end also.
Title: Re: NGINX does'n start after update to 22.1.9
Post by: Fright on June 26, 2022, 08:47:26 am
the updated templates need to be applied, so you need to click Apply on SERVICES: NGINX: CONFIGURATION page imho
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 26, 2022, 10:04:17 am
@Fright:
One thing i noticed is that when i stop and start nginx, or apply changes in niginx and go to a website behind nginx i get this error:
MOZILLA_PKIX_ERROR_REQUIRED_TLS_FEATURE_MISSING

When i go to the same webpage again, the error is gone and works.

In ACME Client Certificates - i have [OCSP Must Staple] checked
in NGINX i have [http server] - [OCSP Stapling] checked and [OCSP Verify] checked

Is this a normal error for first time website url visit after a restart or refresh of settings or some error on my end or some bug in nginx?
Title: Re: NGINX does'n start after update to 22.1.9
Post by: ThyOnlySandman on June 26, 2022, 10:24:01 am
Yes NGINX was stopped after first boot from upgrade.  And when trying revert + install + patch.
I did try to apply on NGINX service config - can't remember if it was with reverted or new/patched.
I always get manual full vmware VM backup prior to updating.  I just restored back to 22.1.8_1 for now.  Revisit in a bit.
Title: Re: NGINX does'n start after update to 22.1.9
Post by: Fright on June 26, 2022, 10:36:10 am
@RamSense
its a nginx bug feature - "ocsp lazy loading". need to hit every server after nginx restart or use ssl_stapling_file and maintain responses yourself
https://trac.nginx.org/nginx/ticket/1998
Title: Re: NGINX does'n start after update to 22.1.9
Post by: RamSense on June 26, 2022, 11:00:16 am
@RamSense
its a nginx bug feature - "ocsp lazy loading". need to hit every server after nginx restart or use ssl_stapling_file and maintain responses yourself
https://trac.nginx.org/nginx/ticket/1998

Thnx!
Title: Re: NGINX does'n start after update to 22.1.9
Post by: PIv0 on June 27, 2022, 09:43:40 am
Upgrade to latest and apply patch afterwards. Applying patch twice will undo the patch.

I confirm everything works!

Thanks for the patch info!

1. opnsense-revert -r 22.1.8 os-nginx (again now)
2. upgraded nginx to v 1.28 from the opnsense gui
3. run the patch from terminal: opnsense-patch -c plugins a357676
Title: Re: NGINX does'n start after update to 22.1.9
Post by: vinz81 on June 27, 2022, 07:14:21 pm
I had the same issue this morning. Tried to revert, upgrade and patch as suggested but it didn't work.

I commented "js_include" directive  in /usr/local/etc/nginx/nginx.conf and nginx finally started (v1.27).

I stay with this temp fix for now, waiting for a patch.
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: jimlano on July 10, 2022, 10:13:06 pm
Dear all,
I tried the 3 steps and the jsinclude problem went away. But another one came up

Code: [Select]
BIO_new_file("/usr/local/etc/dh-parameters.4096") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/usr/local/etc/dh-parameters.4096','r') error:2006D080:BIO routines:BIO_new_file:no such file)

Does anyone have a clue? Thanks!
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: marcelmah on July 11, 2022, 06:41:22 pm
Just updated to 22.1.10 and can't start NGINX anymore...
unknown directive "js_include" in /usr/local/etc/nginx/nginx.conf:40

Restoring to older version of NGINX does not help (opnsense-revert -r 22.1.8 nginx):
SyntaxError: Illegal export statement in ngx_functions.js:51, included in /usr/local/etc/nginx/nginx.conf:40
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: franco on July 12, 2022, 08:48:49 am
Which mirror are you using or are you managing a mirror yourself? It was fixed in a hotfix update.


Cheers,
Franco
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: marcelmah on July 12, 2022, 12:36:38 pm
Which mirror are you using or are you managing a mirror yourself? It was fixed in a hotfix update.


Cheers,
Franco
Hi,

I'm coming from OPNsense 22.1.8_1-amd64 using mirror OPNsense in Amsterdam.
When I check for update I only see 22.1.10, so I skipped 22.1.9 and 22.1.9_1.
Is there a 22.1.10_1?
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: franco on July 12, 2022, 12:54:12 pm
It looks ok to me. What version is your nginx plugin?
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: marcelmah on July 12, 2022, 12:55:35 pm
It looks ok to me. What version is your nginx plugin?
This is what I get (amongst the rest of the packages) when I open the update page:
nginx   1.20.2_9,2   1.22.0_6,2   upgrade   OPNsense
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: franco on July 12, 2022, 03:04:10 pm
I mean the plugin os-nginx. Maybe you locked it.


Cheers,
Franco
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: marcelmah on July 12, 2022, 03:08:10 pm
I mean the plugin os-nginx. Maybe you locked it.


Cheers,
Franco
This is now: os-nginx (installed)   1.27   902KiB   OPNsense   Nginx HTTP server and reverse proxy
You want to know what version it is when I've updated to 22.1.10 again?
If so, I think I can try again this evening.
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: franco on July 12, 2022, 03:36:53 pm
Yes so the latest version is 1.28_1 as you can see from the link:

http://mirror.ams1.nl.leaseweb.net/opnsense/FreeBSD%3A13%3Aamd64/22.1/latest/All/os-nginx-1.28_1.pkg

1.27 definitely doesn't work with the latest nginx software shipped.
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: marcelmah on July 12, 2022, 06:54:10 pm
Yes so the latest version is 1.28_1 as you can see from the link:

http://mirror.ams1.nl.leaseweb.net/opnsense/FreeBSD%3A13%3Aamd64/22.1/latest/All/os-nginx-1.28_1.pkg

1.27 definitely doesn't work with the latest nginx software shipped.
Just updated again 22.1.10
NGINX won't start: os-nginx (installed)   1.28_1   908KiB   OPNsense   Nginx HTTP server and reverse proxy

same error: unknown directive "js_include" in /usr/local/etc/nginx/nginx.conf:40
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: franco on July 12, 2022, 08:35:10 pm
If you apply your nginx configuration it should work, otherwise it just keeps the old one until reboot.


Cheers,
Franco
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: marcelmah on July 12, 2022, 09:27:05 pm
If you apply your nginx configuration it should work, otherwise it just keeps the old one until reboot.


Cheers,
Franco
Hi,

This is weird, I just loaded my snapshot (I run OPNsense in an ESXi VM) of my last test (faster then updating again from 22.1.8_1) and this time everyting booted and started fine. I could swear I did a reboot yesterday after I discoverd the problem...
Title: Re: [SOLVED] NGINX does'n start after update to 22.1.9
Post by: franco on July 13, 2022, 09:14:01 am
Solved is solved :)