Adding the headers-more-nginx-module to NGINX - 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.

Related

Unable to change options for ngx_pagespeed

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.

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).

Using luac file on Nginx

I have been experimenting with using Lua in Nginx - quite a neat little capability which I can use effectively. However, one of my concerns relates to IP protection so I thought I would use an online tool to compile my, fully tested, LUA script. I tried https://luac.mtasa.com/.
I uploaded the file to my server, changed by /etc/nginx/sites-available/default file to use the luac* instead of the orginal lua and reloaded nginx. However, when I attempt to browse to the resource that is being serviced by that lua(c) I get the error log message *70 failed to load external Lua file... : bad byte code header. How should this be interpreted? The options are
That particular online compiler is not generating a valid luac.
The nginx/lua combo does not understand that particular luac.
I should mention that I am using Nginx 1.6.2 on Ubuntu 14.10 (64 bit). I installed Lua enabled Nginix via apt-get install nginx-extras.
I am a beginner here.
Compiling lua for nginx has some specifics. You could see details on official Lua module page http://wiki.nginx.org/HttpLuaModule#Lua.2FLuaJIT_bytecode_support

NGINX directing to /usr/share/nginx/www/html after update

Today I updated my webserver, and while I do have a backup, I wish to resolve the following issue.
After a reboot after the apt-get update and apt-get upgrade, NGINX started to ignore the virtual-hosts.
The domains are still operational, but they are directed to the /usr/share/nginx/www/html/index.php file apparently, which contains: 'phpinfo();' in php tags.
The 'default' file for virtual-hosts and original conf settings are not present, only my customized nginx.conf. Therefore I have already ran out of possible issue's I can think of.
After the upgrade it seems that indeed some files in etc/nginx/ were changed, I replaced all files in there with my backup and it works just fine again.
Not much of an answer maybe, but if you have a backup, than you can fix the issue.
And it at least gives you a starting point as for where to look to fix the issue by hand.

Elgg Installation Problems

I am running Apache2.2, with PHP5 and mod_rewrite enabled on a VPS running Ubuntu Hardy. And I am trying to install Elgg1.5. I uploaded it to /var/www, and changed the appropriate permissions.
When I hit the url, it brings me to the installation page where I provide the database info. When I submit the page, I get the following error in my access.log
"Cannot modify header information - headers already sent by (output started at /var/www/engine/lib/._access.php:1)" in file /var/www/engine/start.php (line 182)
I don't see any problems within the .htaccess and engine/settings.php file it creates, and no whitespaces before and after the php tag. Since I haven't hand-touched any files, I have no clue whats causing the error. Anyone's played with Elgg1.5 ?
Problem solved. It was some corrupt file.

Resources