Unable to change options for ngx_pagespeed - nginx

I was able to successfully add ngx_pagespeed to my Nginx server at Digital Ocean. I did an automated install per this: https://www.modpagespeed.com/doc/build_ngx_pagespeed_from_source
The module works - for example I can see it is automatically converting my .jpg images to .webp. Also, curl -I -p http://localhost| grep X-Page-Speed returns the X-Page-Speed: 1.13.35.2-0 header.
However, I’m not able to edit any options. When I try to run something like pagespeed rewrite_images on, or even pagespeed on, I get an error pagespeed: command not found.
Per documentation pagespeed should be the command for Nginx: https://modpagespeed.com/doc/configuration
I tried a couple of other commands:
whereis pagespeed returns pagespeed:
which pagespeed returns nothing.
As far as I know these should be returning the full path, something like /usr/bin/pagespeed

Problem was that for some reason I thought pagespeed flags were turned on/off via terminal commands. This assumption is wrong. It actually needs to be done as Nginx directives, added to nginx.conf file and restart the Nginx server.

Related

How can I get niginx fastcgi to run requests in parallel?

I'm trying to get nginx to serve more than one connection at a time, with a fasgcgi backend.
This stackoverflow answer might contain the answer, but neglects to say where that option could be configured. All the options I see are in config files. Where would I put command line options like "-c 2"? It's not nginx -c, that's config. I don't see anyplace that looks like it would take command line options.
Ok, it looks like I don't need the above linked answer. The setting is
FCGI_CHILDREN
And the reason I had a bit of finding this is that this setting is not in nginx's config, it's in fcgiwrap's config. That is (on my machine) in /etc/init.d/fcgiwrap. Change FCGI_CHILDREN to something larger than 1.
FCGI_CHILDREN="5"
Just changing that to greater than one allow me to run more than one request at a time.
The linked answer mentions
if you are using spawn-fcgi to launch fcgiwrap then you need to use -f "/usr/bin/fcgiwrap -c 5"
but I did not have to do that.

Adding the headers-more-nginx-module to NGINX

I've been trying so hard to resolve this myself over the last week or so but I'm banging my head against a brick wall now!
Long story short, I'm getting a CORS error and I've been trying to fix the issue using the add_header 'Access-Control-Allow-Origin' '*' always; command in every place I can think of and with commas and single quotes in various places. My nginx install is a mainline release 1.15.3 on CentOS 7.
I soon figured that this module must be installed by default and adding the above line to the location / {} block in default.conf should be fine. I then added the extension to Firefox to make sure it worked (as a temp measure) and found that I got a 500 error. So now (not sure why) I have the extension disabled and the above line added to the default.conf file and I'm still getting the 500 error - which is good in a way! Now I want to install the -more- module to get over the 500 error I am now getting, as to my understanding the basic header module cannot deal with 500 errors.
My biggest problem at the moment is not being able to add this module to my nginx install. Looking online I see instructions for recompiling nginx with the module using the ./configure command (./configure --prefix=/opt/nginx --add-module=/path/to/headers-more-nginx-module) but I have no configure file in my nginx root directory (which is actually etc/nginx). I have no idea how to handle this really and could do with some advice please.
I did run nginx -V to list the modules that where supposedly installed with my instance of nginx but there was no mention of any header module so my assumption of the basic module being installed out of the box could also be wrong.

Enabling gzip for external http requests

I have a local env that is not automatically decompressing deflated files. The staging server and the production server seem to be doing it automatically (because the code we have up there is working fine) but on my local machine the request body is still compressed. I had some success using:
gzinflate()
but I would rather find a solution where my local set up is just closer to the production set up (and don't have to change the code all that much).
p.s. this is a wordpress set up.
K I figured it out. Turns out the issue was that I had just updated my local env to php 7 and enabled x-debug. When doing this I also needed to install something for SOAP and CURL requests (if someone would like to explain further I would be appreciative). Here is the command I had to run:
sudo apt-get install php-soap php-curl

Change Jenkins basepath

I'm trying to serve a stock jenkins installation (on Amazon Linux AMI) thru myjenkinsinstance:8080/jenkins (rather than myjenkinsinstance:8080), and then proxy this with e.g. Nginx (over HTTP).
This question has been 'answered' before, but the solution doesn't seem to be relevant anymore.
#admins I would prefer to comment on that thread (specifically this 'answer'), rather than opening a duplicate, but I am not allowed to, per my 'reputation' score (as my comment would not be a solution at all, but further request for help).
From the closest thing to an answer I've seen:
Go to Jenkins Home Directory ( I have mine in C:\Jenkins)
Edit jenkins.xml
Add this --prefix=/jenkins to the end of the argument as show below and restart the jenkins service ALL worked OK for me !
Example : <arguments>-Xrs-Xmx256mDhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --prefix=/jenkins</arguments>
Open Url http://localhost:8080/jenkins this should bring up the home page of jenkins
there is no 'jenkins.xml' in the $JENKINS_HOME directory, but there is a config.xml
there is no <arguments/> entry in the config.xml
there seems to be no other configuration for the initial installation
There's also a 'Jenkins Location > Jenkins URL' setting in the "Configure System" settings (myjenkinsinstance/configure), but modifying this seems to have no noticeable affect.
The end goal would be to automate this installation via e.g. CloudFormation (as part of the EC2's UserData).
Any suggestions would be greatly appreciated.
On your linux system, you need to find the jenkins default config file located at
/etc/default/jenkins
and then add the following arguments according to your requirements. This is a rough idea.
JENKINS_ARGS="--webroot=/var/cache/jenkins/war --prefix=/jenkins
--httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT"
This should work most likely. If it doesnt, pls update your answer with the current arguments present. This works fine for Debian/Ubuntu.
Also you are running jenkins on your windows machine or linux?
So my 'solution' was to use sed and insert some lines into /etc/nginx/nginx.conf and /etc/init.d/jenkins.
e.g.
sed -i '/^ location \/ {/aproxy_pass http://127.0.0.1:8080/;' /etc/nginx/nginx.conf
sed -i '/^PARAMS=/ s/"$/ --prefix=\/jenkins"/' /etc/init.d/jenkins
I highly doubt this is anything near a 'best practice', but it seems to work for now (what happens were I to update with yum... I'm not sure, but the plan is to back the instance with an Elastic Filesystem, which hopefully will allow us to consider the jenkins instance ephemeral, anyway).

nginx says it's stopping but doesn't actually stop

I installed nginx with phusion using the passenger-install-nginx-module installer.
This worked. After installing and visiting my domain, I see the Welcome to nginx page.
However, the service nginx {start|stop|restart} commands don't work.
After a quick google search, I found this: https://askubuntu.com/questions/257108/trying-to-start-nginx-on-vps-i-get-nginx-unrecognized-service
which I executed and found that the script gets executed (e.g. prints Stopping nginx:, but it doesn't actually stop the server, because I can still see the webpage and no status is printed such as [ OK ].
How can I get the service commands for nginx to work.

Resources