Get the most out of your Centmin Mod LEMP stack
Become a Member

Nginx NGINX Plus on Amazon EC2 – Getting Started

Discussion in 'Nginx and PHP-FPM news & discussions' started by eva2000, May 25, 2014.

Tags:
  1. eva2000

    eva2000 Administrator Staff Member

    30,965
    6,918
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,420
    Local Time:
    2:58 AM
    Nginx 1.13.x
    MariaDB 5.5
    Basic Installation


    Getting started with NGINX Plus is easy! We provide two supported AWS Marketplace instances of NGINX Plus (based on Amazon Linux or Ubuntu) which are available as a free trial and on a pay-by-use basis.

    Amazon’s Getting Started guide gives you a quick introduction to the process of launching
    AMI instances, though it’s really as simple as ‘Subscribe’ and ‘Launch’.


    [​IMG]

    The AMI images above contain the following components:

    • The latest version of NGINX Plus for use with AWS, with access to a private repository for future NGINX Plus updates
    • A set of pre-packaged configurations to build highly available NGINX Plus configurations
    • A helper script used to install and configure common development environments with NGINX Plus.

    When you launch a new instance, NGINX Plus will start automatically and will be configured to serve a default index.html page. Use the control panel to determine the public DNS name for the instance and access this using a web browser:

    [​IMG]

    Troubleshooting – Security Groups


    If the connection times out and you don’t see the default web page, it’s most likely that the EC2 security group that was assigned to the instance does not permit HTTP traffic. You can create a new security group that admits HTTP (port 80) and HTTPS (port 443) traffic from all sources, and locks down SSH so it’s only accessible from your IP address:

    [​IMG]

    [​IMG]

    Check the status of the running instance


    Now, connect to the instance using SSH and check the status of NGINX Plus:

    user@localhost$ chmod 400 aws_cert.pem
    user@localhost$ ssh -i aws_cert.pem ubuntu@ec2-54-86-83-172.compute-1.amazonaws.com
    ...
    ubuntu@ip-172-31-20-254:~$ /etc/init.d/nginx status
    * nginx is running
    High Availability


    You can deploy a cluster of NGINX Plus instances behind Amazon ELB, or you can configure NGINX Plus to operate in a standalone high availability cluster.

    NGINX Plus with Amazon ELB


    If you run NGINX Plus behind Amazon ELB, then you can use ELB and Route53 for high availability across multiple availability zones. ELB’s health checks will determine if the NGINX Plus instances are running correctly, and each NGINX Plus instance runs completely independently.

    Amazon ELB functions as a layer 7 HTTP proxy (much like NGINX Plus). If you want to determine the true source IP address of a client connection that is forwarded to NGINX Plus, you can inspect the X-Forwarded-For header that is added by ELB, using the real_ip module in NGINX Plus.

    If you plan to deliver applications over SPDY or using WebSockets, then you need to know that ELB does not terminate SPDY traffic or forward websockets connections. In this case, you need to configure ELB to perform TCP load balancing (rather than HTTP/HTTPS), and you should use the Proxy Protocol to forward source IP addresses.

    NGINX Plus high-availability clustering


    If you run NGINX Plus as a high-availability cluster, then you can avoid the use of Amazon ELB and your clients connect directly to the NGINX Plus instances. The NGINX cluster uses Corosync and Pacemaker to monitor its internal health and move elastic IP addresses to correctly-functioning NGINX Plus instances.

    Use the following command to install the required software:

    $ sudo nginx-ha-setup

    You can then refer to the detailed instructions in the High Availability article.

    Amazon EC2 Use Cases


    The Amazon AMIs include a helper script to optionally configure NGINX Plus for different web frameworks:

    $ sudo nginx-setup

    The helper script automatically installs all prerequisite packages, prepares the necessary template configuration and creates a user account for each application. After the installation completes the web application will reside in a subdirectory inside /var/www, and its relevant template configuration for NGINX Plus will be placed in the /etc/nginx/conf.d directory.

    For more information, check out the documentation at http://nginx.org/en/docs/howto_setup_development_environment_on_ec2.html.

    nginx-setup may be used to install and configure PHP-FPM, Ruby on Rails, Django and Pyramid. It’s provided as a convenience; for a production deployment, you may wish to configure your application framework manually to ensure that it meets your requirements accurately.

    The post NGINX Plus on Amazon EC2 – Getting Started appeared first on NGINX.

    Continue reading...