Customize Nginx config on Ruby1.9 Elastic Beanstalk

Requirement : Set a URL redirection in Nginx Configuration.

Example :

download.appygeek.com => https://play.google.com/store/apps/details?id=com.mobilesrepublic.appygeek

On Beanstalk with Phusion Passenger Standalone [3.0.17] (Ruby1.9), Nginx customization is highly discouraged. However to accomplish this, the following workaround is done :

Beanstalk generates the nginx configuration file from a ERB template each time when restarted. Hence the configuration change has to be made at the ERB template instead of Nginx configuration.

Location of the ERB Template file = /usr/share/ruby/1.9/gems/1.9.1/gems/passenger-3.0.17/lib/phusion_passenger/templates/standalone/config.erb

Following contents are appended before the last closing curly bracket:

server {
 listen 0.0.0.0:80;
 server_name download.appygeek.com;
 root '<%= app[:root] %>/public/test';
 index index.html;
}

File Saved, phusion-passenger-nginx configuration is combined and it is Restarted

/etc/init.d/passenger restart

Create the Dir /var/app/current/public/test and a file called index.html with the below contents in it:

<html>
<head>
<meta http-equiv="refresh" content="0; url=https://play.google.com/store/apps/details?id=com.mobilesrepublic.appygeek" />
</head>
</html>

Hence the Nginx is customized.

Note : For Permanent fix we have to take Custom AMI and launch the ElasticBeanstalk environment.

 

Click this URL on Nginx Customization @ AWS Forum

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s