Consul template is not restarting nginx windows - nginx

I am using consul template v0.19.0 for windows, for rendering nginx config.
The nginx config Is rendering fine by the consul template but It is not restarting the nginx.
This is the command I am using.
Consul- template -consul-address="xx" - template="in:out:{{pathfornginx}}\nginx.exe -s reload" .
Where "in" is the ctmpl path and "out" is the final nginx config path..
I have tried with different path format but no luck.
Could anyone drop some input on this.
Thx in advance.

Did you tried to create a config.json file which will contain the path to the ctmpl file, and the command itself?
You would need to use the -config flag instead of -template
If you want an example for the config.json I can provide you one.. I'm using similar setup and it works fine for me
Provide me a better solution?

Related

serve assets file with invaid names with nginx

I have download a full wordpress website with below command:
wget -r --convert-links --no-parent website_url
I want to server this site with nginx but there is a problem.
some of files has an invalid names with version like js_composer_front.min.js?ver=6.0.5 and nginx throw 404.
how can I solve this problem?
As far as I know, you can't fix the mentioned issue with Nginx and Wget, you should write script to modify generated links, maybe sed or python script.
I think the better solution is to use simply-static plugin.

Symfony's framework.ide config for PhpStorm and Vagrant

How do I set up framework.ide config value so that it properly links to files in PhpStorm, when the code is run from Vagrant?
I've tried phpstorm://open?file=%%f&line=%%l
but it gives me Vagrant paths, like:
phpstorm://open?file=/vagrant/src/AppBundle/Controller/DefaultController.php&line=27
while I should be getting host paths, like:
phpstorm://open?file=/Volumes/my_project_volume/project_name/src/AppBundle/Controller/DefaultController.php&line=27
I guess the solution would be to somehow configure path mapping, either in Symfony or in PhpStorm.
Regarding symfony's official documentation:
https://symfony.com/doc/current/reference/configuration/framework.html#ide
you can use (from symfony 3.2) something like this:
ide: 'phpstorm://open?file=%%f&line=%%l&/path/on/vagrant>/your/local/path/'
For a project relative directory:
framework:
ide: 'phpstorm://open?url=file://%%f&line=%%l&/path/in/server>%kernel.project_dir%'
When working with Docker and with Mac, and your project is hosted in your user folder, the configuration has to slightly get changed as well.
framework:
ide: 'phpstorm://open?file=%%f&line=%%l&/app/>/Users/your-username/PhpstormProjects/your-project-folder/'
Please note that
/app/ is the path inside the Docker container,
using ~/PhpstormProjects as alias to the home directory is something PHPStorm does not seem to support

Nginx fails to create directories on Windows 10 with error: nginx: CreateFile()...failed

I need to find a way/setting to allow Nginx to run a .bat file that will create directories and files via a WINDOWS service; my OS is Windows 10.
Currently, our windows service fails to create directories and files with the following:
CreateFile()
"C:\someForlderName\build\distribution.\nginx/logs/error.log" failed
(3: The system cannot find the path specified)
Somehow Nginx doesn't have enough permissions to perform write-access operations like creating directories such as /logs/ and /temp/ within the /Nginx/ directory.
Anybody ran into this problem before?
I was facing the same problem, sharing the thing that worked for me.
Nginx is showing this error because... nginx didn't find the error.log file..
For that,
Go to you nginx folder where other folders like conf, docs, html etc are their as.
Create folder name logs, and in that folder create a file name error.logas.
see the right way in picture..
If your Nginx is at D:\nginx\nginx.exe, execute this to start nginx
D:\nginx\nginx.exe -c D:\nginx\conf\nginx.conf -p D:\nginx\
For Nginx on Windows, you need to execute nginx server related command from respective home directory where nginx configuration file is located.

Error:No such file or directory when tried to access nginx.conf using path /opt/nginx/conf/

When i tried to configure the webserver through the path cd /opt/nginx/conf/ an error appears /opt/nginx/conf.Hope some one will have the answer here.Thank you
probably your config is under /etc/nginx, to check which directories nginx is using you can use the command whereis nginx

Exec with PHP-FPM on nginx (under chroot) returns nothing

I've created a nginx server in a chroot at /srv/http with php-fpm. Both services use the http user and it works fine. The problem comes when I try to run an exec command such as
echo shell_exec('/usr/bin/ls');
There is no output at all on the web page or in the errors. I've also tried
error_log(shell_exec('/usr/bin/ls');
and still nothing.
Things I've Tried or Know:
safe mode off
exec enabled
user is http (using phpinfo())
display_errors = on
error_reporting = E_ALL
sudo /usr/bin/chroot --userspec=http:http /srv/http ls works fine
Can create file and read from it using file_puts_content and fopen/fread
tried shell_exec,exec,system, and passthrough - nothing worked
tried appending 2>&1 to the end of the command and nothing
I've copied all the executables and libraries necessary over
all libraries, binaries, and everything under /srv/http/www (where the webpages are) have executable and read permissions
doc_root is www
As far as I know, everything works in the chroot, except shell commands through php-fpm. Anyone have any idea where I went wrong and how to fix it?
This may sound stupid but you must just copy /bin/sh (not /bin/bash!) to you chroot.
For example see this question: How do I change the shell for php's exec()
If you chroot to some directory, then this directory becomes the root for all your PHP scripts. That means, that if you execute /usr/bin/ls from within PHP, it will try to exectue /srv/http/usr/bin/ls instead.
You can copy the executable to that directory - but be aware of the security implications. If you copy critical system executables into the chrooted directory you basically bypass the positive effects of chroot.
I get no output for
echo shell_exec('/usr/bin/ls');
either. Presumably because ls isn't a file but a built-in command. Running:
echo shell_exec('ls');
outputs:
css demos favicon.ico images js path.php robots.txt routing.php test
which is the list of files in my root directory for the site.

Resources