Install Extensible Service Proxy on GCE/RHEL7 - nginx

Quickstart for Endpoints on Compute Engine says
you need to run the Extensible Service Proxy before sending requests
to the API
But it also says
This quickstart works only on Debian. Make sure you create a VM that
runs Debian.
I have an existing GCE VM instance running Red Hat EL 7 that I'm adding this Endpoint to. Where are instructions for installing and running Extensible Service Proxy on it?
FWIW I examined the contents of the Debian package. It appears to be just nginx with custom configs and some extra scripts. If there's no RPM or other way of installing ESP on RHEL7, can I just manually install the contents extracted from the .deb package?

Yes, it should work (not tested). nginx in the .deb package is a statically compiled binary with a custom module that runs fine standalone. Please make sure to place the remaining files (config templates, root CA certificates, start-up script) in the same directories as in the .deb package.

The instructions for installing the ESP are implied in the instructions for installing the Cloud SDK on Red Hat and CentOS, since the endpoints-runtime RPM is available from the same repo as is the SDK.
$ sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOM
$
$ sudo yum install google-cloud-sdk
Note that the ESP installs as nginx, with supporting scripts and config files, that will replace any existing nginx and any files with the same name, which will overwrite any existing nginx functionality (like proxy, cache etc). It might be best to archive any host-specific nginx configs first, then install ESP, then merge old configs into the new ones installed by yum.

Related

Is Passenger Deprecated for Nginx versions above 1.14?

I updated nginx from version 1.14 to 1.18 (Ubuntu) on Ubuntu 18.04.
Doing so appeared to break passenger. So I uninstalled and attempted to reinstall the Open Source Passenger version via the Passenger installation Ubuntu 18.04 instructions.
I got to this line:
sudo apt-get install -y libnginx-mod-http-passenger
Which throws this error
libnginx-mod-http-passenger : Depends: nginx-common (< 1.14.1) but 1.18.0-3ubuntu1+bionic1 is to be installed
Update I also attempted with the enterprise version. Following the enterprise version installation instructions, I received a similar error message:
libnginx-mod-http-passenger-enterprise : Depends: nginx-common (< 1.14.1) but 1.18.0-3ubuntu1+bionic1 is to be installed
I did attempt to research the issue and I found this issue on Phusion's GitHub as well as this more recent issue. It appears that what most people are doing is rolling back their nginx version to 1.14.
It is not deprecated, no. The problem is that the packaged module you are trying to install was made for an older Nginx version that is distributed through the system default repository. This appears in the installation guide that you've mentioned:
At this point we assume that you already have Nginx installed from your system repository.
What this means is that the following instructions assume that you have Nginx specific version (1.14.0 in your case) installed, for which the packaged module was built. This is emphasised in the new passenger documentation:
If you want to use our packaged Nginx module, you must use your distro's provided Nginx package. If for example you have the repo provided by NGINX setup, you will instead need to compile a dynamic module compatible with that Nginx.
The link in the last quote will bring you to the guide on how to compile a dynamic passenger module and enable it in Nginx configuration. I will not repeat the whole process to keep the answer short but the general approach is this:
Get passenger module for Nginx source code.
Get Nginx source code for the version you have installed.
Compile Nginx with the passenger module:
cd /path-to-nginx-source-dir
./configure --prefix=/opt/nginx \
--with-some-configure-flag \
--add-dynamic-module=$(passenger-config --nginx-addon-dir) \
--add-module=/path-to-some-other-nginx-module
make
sudo make install
Make Nginx to load the module by adding this line to nginx.conf:
load_module modules/ngx_http_passenger_module.so;
Personally, I'd rather chosen the 'nginx-behind-nginx' approach than building the module. That is you have Nginx any version you like but it runs as a reverse proxy for another Nginx with passenger enabled (Passenger Standalone). With an unnoticeable penalty to performance this will be much easier to maintain (install, update). See this guide for details.

How to upgrade nginx to latest on Amazon Linux AMI 2018.03?

I have an Elastic Beanstalk web application using Amazon Linux AMI that requires the latest build of nginx. The nginx build that comes with AMI version 2018.03 is version 1.12.1, whereas the latest stable build on nginx.org is 1.15.4. Only 1.12.1 is available from Amazon's yum repositories. The preferred strategy we would like to use would be to create a custom RPM and pull that from an endpoint and install. How would I go about creating a custom RPM of nginx that would run on Amazon Linux? Or is there a pre-built source that I could take advantage of?
It turns out the best way to do this is to create a custom AMI. You can find instructions on how to create a custom AMI here:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.customenv.html
And how to install from source here:
How to install nginx 1.9.15 on amazon linux disto
If you want to swap out a running instance try here:
https://www.photographerstechsupport.com/tutorials/upgrade-running-nginx-amazon-linux/
I personally got it working with a mix of the code from those two sources. I also had to yum install gcc to get make to work, and had to manually add the folder /var/cache/nginx before the nginx service would work. Happy upgrading!

Recompile Nginx with additional modules

I installed Nginx via apt-get on Debian a while ago, and I've got a couple of sites live on it. Now I need to install some additional modules, and as I don't want to mess anything up I'd like to double check my process before I perform it. Hopefully this will also help others that are unsure about this part.
As I've understood it I have to do the following to minimize the downtime:
Download the source for Nginx
Add the additional modules with ./configure --additional-module
Compile Nginx with make
Stop the current server (service nginx stop)
Install Nginx with make install
Start the new server (service nginx start)
Or do I have to uninstall Nginx first, as it's not compiled from source at this point?
Having done something similar on Ubuntu before, the installation should overwrite the existing nginx binaries with the newly compiled ones, so long as yes, you ensure nginx isn't running on the system at the time.
I'd recommend trying to install nginx elsewhere on the system, so in case you can't get it to work quickly, you can restart your web server with the old nginx binaries and not have significant downtime.
nginx -V - helpful command which shows options for .\configure which was used to make nginx, which is actually working.
Helpful to get detail imagination about.
apt-get source nginx - to get source
install will automatically substitute actual installed version by new one
Keep also in mind that some nginx-modules can require additional libs on server. geoip module is classical example of it

amazon ec2 micro RHEL: how to install nginx or others?

I chose micro free RHEL6.4 instance with EC2/Amazon, when I login, I found there no gcc, which I can yum install it. and there no nginx to yum install ?
I must install gcc and develop tools and download nginx source code to install ? oh ,the free is only 30Gb one month?
Check the installation page inside nginx website

How to configure additional modules to nginx after installation?

I have installed Nginx in our redhat machine using rpm. Now we want to add nginx-rtmp module, but inorder to add new module as per the document i need to build it by downloading the tar ball. Does it mean that i have to remove the rpm and install it as per the document.
Ref: https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp
./configure --add-module=/usr/build/nginx-rtmp-module
make
make install
With nginx 1.9.11, it's not necessary to recompile the server, as they added support for dynamic modules. Take a look here:
https://www.nginx.com/blog/dynamic-modules-nginx-1-9-11/
Unlike Apache, all modules, including the 3rd party modules, are going to be compiled into nginx. So every time you want to add a new module, you have to recompile nginx.
So yes, you have to install it as per the document. There is no much value of keeping 2 nginx runtimes on the same server any way. So you may also want to remove the previous nginx.
I had a similar problem where the auth-pam module broke after an upgrade. Here's what fixed it for me (debian stretch/sid, nginx 1.10.2):
apt install libnginx-mod-http-auth-pam
ln -s /usr/share/nginx/modules-available/mod-http-auth-pam.conf /etc/nginx/modules-enabled/50-mod-http-auth-pam.conf
The config file contains a single “load_module” directive which tells nginx to dynamically load the module on startup. As jekennedy mentioned, this would only apply to newer versions of nginx that support dynamic module loading.
Yes, you have to uninstall nginx (installed via rpm) and re-install it according to the mentioned document that is from source file. There are some disadvantages of installing nginx using source, like you cannot use nginx as a service. Here, you can find instructions to do same thing with all the functionalities you get while installing nginx using OS-respective packages.
Following the steps in this post from the nginx blog page called "Compilation of Dynamic Modules for NGINX Plus", i could compiled the RTMP módule, downloading the nginx-rtmp-module from Github and import it on my webserver.
Regards.

Resources