nginx with grunt-nginx - paths on Windows - nginx

I have nginx installed to c:\nginx\, and a node app at c:\node\stock\. I have my gruntfile.js at c:\node\stock\gruntfile.js.
I tried config: 'c:\\nginx\\conf\\nginx.conf' and prefix: 'c:\\nginx'. Also config: '../../nginx/conf/nginx.conf' and prefix: '../../nginx/'.
I'm getting this error message:
Exception thrown in attempt to start nginx: Error: Error: not found: nginx
What should these paths be..?

The author of grunt-nginx (https://github.com/alexcurtis) answered my question on github.
You have to add the PATH to nginx (c:\nginx in my case) into your Windows environment variables, then restart your console.

Related

Kong with OWASP ModSecurity optional configuration include

For customizing of ModSecurity configuration I have included to the modsecurity.conf following line:
Include /etc/modsecurity/*.conf
But without any conf file in the directory (usual case on my enviroment), a kong failing during startup
Error: could not prepare Kong prefix at /usr/local/kong: nginx
configuration is invalid (exit code 1): nginx: [emerg]
"modsecurity_rules_file" directive Rules error. File:
/usr/local/kong/modsecurity.conf. Line: 268. Column: 31.
/etc/modsecurity/.conf: Not able to open file. Looking at:
'/etc/modsecurity/.conf', '/etc/modsecurity/.conf',
'/usr/local/kong//etc/modsecurity/.conf',
'/usr/local/kong//etc/modsecurity/*.conf'. in
/usr/local/kong/nginx-kong.conf:69 nginx: configuration file
/usr/local/kong/nginx.conf test failed
IncludeOptional not supported by kong.
How I can solve the case with optional include?
Kong version 1.2.X

Run nginx.exe on Windows as another user

I'm working on a project for deploying pentest lab with terraform & ansible. All is working good except that last problem.
In my lab I have a nginx server running on a Windows server. Nginx with php works when I start them as Administrator with ansible but i need them to run with a non admin local account.
For the php i've made a wrapper using this tools : https://github.com/antonioCoco/RunasCs
But it doesn't work with nginx cause of a working directory problem :
Here is the error :
PS C:\Users\Administrator> .\RunAsCs.exe nginx ***** C:\Web\nginx-1.19.6\nginx.exe
[*] Warning: GetUserProfileDirectory failed with error code: 2
[*] Warning: Unable to obtain environment for user 'nginx'.
[*] Warning: Environment of created process might be incorrect.
nginx: [alert] could not open error log file: CreateFile() "logs/error.log" failed (3: The system cannot find the path specified)
2021/03/06 10:18:33 [emerg] 5556#6124: CreateFile() "C:\Windows\system32/conf/nginx.conf" failed (3: The system cannot find the path specified)
And that's normal because as you can see my wrapper start in Windows/System32
I would like to know if there is a solution either with nginx.conf or with ansible to start this exe as the "nginx" user.
This is a working code for starting nginx as Administrator
- name: Starting web server
win_shell: .\nginx.exe
args:
chdir: C:\Web\nginx-1.19.6
async: 180
poll: 0
I know that there is a psexec module in ansible but psexec will work only for Local Admin account and the goal of that is that my nginx don't run as Local Admin.
Thanks for the help !

Problem with brotli configuration in nginx

I am following this guide https://www.vultr.com/docs/add-brotli-support-to-nginx-on-ubuntu-18-04
I have followed every step but I am stuck at Step 4 – Configure Nginx
When I add to nginx.conf
load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;
I get this error after running sudo nginx -t:
nginx: [emerg] dlopen() "/usr/share/nginx/modules/ngx_http_brotli_filter_module.so" failed (/usr/share/nginx/modules/ngx_http_brotli_filter_module.so: cannot open shared object file: No such file or directory) in /etc/nginx/nginx.conf:6
nginx: configuration file /etc/nginx/nginx.conf test failed
What might cause that?
Thank you!
Hosting provider: DigitalOcean
Server running: Ubuntu 20.04 LEMP
Nginx version: 1.17.10
I had the same issue 2 years back and after a lot of reading and research got it working.
Hope this helps.
I have provided step by step instruction in the answer.
ngx_http_brotli_filter_module.so" is not binary compatible in /etc/nginx/nginx.conf:1

specify server root as a parameter when launching nginx

I've put nginx into /d/webservers/nginx on Windows and added it to the PATH. Now I try to run nginx from different folder but get the following error:
nginx: [alert] could not open error log file: CreateFile() "logs/error.log" failed (3: The system cannot find the path specified)
2015/03/22 10:09:25 [emerg] 5516#3056: CreateFile() "C:\Users\username/conf/nginx.conf" failed (3: The system cannot find the path specified)
It seems that nginx can't find it's server root folder /d/webservers/nginx where config and logs folder exists. Is there any way to pass as an argument the pass to the server root folder? Something like it's done for Apache: httpd -d /d/Webservers/Apache24'
nginx -c d:/webservers/nginx/conf/nginx.conf

Why does Passenger 3.0 with nginx crash on startup(?) then 403s?

On Ubuntu with REE 1.8.7, with nginx 0.8.53 manually compiled with the
Passenger 3 module doc installed as per the docs, I get an error in
the nginx error log when nginx starts:
Unable to start the Phusion Passenger watchdog because it encountered
the following error during startup: Unable to start the Phusion
Passenger logging agent: an error occurred while sending startup
arguments: Broken pipe (32) (-1: Unknown error 18446744073709551615)
I assume this means nginx never starts properly. When I try and view
my site after this, I get a 403.
2010/10/22 00:56:47 [error] 13874#0: *1813942 directory index of "/var/
rails/myapp/current/public/" is forbidden, client: 125.197.115.16,
server: new.myapp.fm, request: "GET / HTTP/1.1", host: "new.myapp.fm"
I expect the first is probably causing the second. I haven't had any
luck googling this. Can anyone provide insight or help me
troubleshoot?
I got this after upgrading to Passenger 3.0.1 as I had not changed the version of Passenger specified by passenger_root in /opt/nginx/conf/nginx.conf. You might need to change the line that looks like this to specify the correct version:
passenger_root /usr/lib/ruby/gems/1.8/gems/passenger-3.0.1;
You get told to do this when you install nginx. Hope that helps.
I ran into this problem too, and it was because passenger couldn't find ruby:
tail -f /var/log/nginx/error.log
2011/12/20 00:54:45 [alert] 30300#0: Unable to start the Phusion Passenger watchdog because it encountered the following error during startup: Unable to start the Phusion Passenger helper agent: it seems to have crashed during startup for an unknown reason, with exit code 1 (-1: Unknown error)
* Passenger ERROR (ext/common/ApplicationPool/../SpawnManager.h:220):
Could not start the spawn server: ruby: No such file or directory (2)
Even though ruby was properly listed within the system PATH, it didn't seem to work right until I added:
passenger_ruby = /usr/local/bin/ruby;
(the location of my ruby executable) into the http section of my nginx config.
The problem was that PassengerLoggingAgent wasn't installed when I did 'gem install passenger'. I installed it as per this discussion (by grabbing it from the standalone zip) and everything is fine now: http://groups.google.com/group/phusion-passenger/browse_thread/thread/323dc1c7b0e5ee11

Resources