Created
September 14, 2012 00:17
-
-
Save nzakas/3718880 to your computer and use it in GitHub Desktop.
Replace Apache with nginx on Elastic Beanstalk AMI (Tomcat7/32-bit)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# IMPORTANT: Run this script as sudo or else it won't work | |
# Original script: http://my.safaribooksonline.com/book/programming/java/9781449309558/hacking-elastic-beanstalk/hackingelectric#X2ludGVybmFsX0ZsYXNoUmVhZGVyP3htbGlkPTk3ODE0NDkzMDk1NTgvSV9zZWN0MTRfZDFlMjAyNQ== | |
echo 'Installing nginx...sit tight' | |
yum -y install nginx | |
echo 'Fixing nginx configuration' | |
sed -i 's/ 1;/ 4;/g' /etc/nginx/nginx.conf | |
rm /etc/nginx/conf.d/default.conf | |
echo 'Messing around with hostmanager so nginx works with it' | |
cd /opt/elasticbeanstalk/srv/hostmanager/lib/elasticbeanstalk/hostmanager | |
cp utils/apacheutil.rb utils/nginxutil.rb | |
sed -i 's/Apache/Nginx/g' utils/nginxutil.rb | |
sed -i 's/apache/nginx/g' utils/nginxutil.rb | |
sed -i 's/httpd/nginx/g' utils/nginxutil.rb | |
cp init-tomcat.rb init-tomcat.rb.orig | |
sed -i 's/Apache/Nginx/g' init-tomcat.rb | |
sed -i 's/apache/nginx/g' init-tomcat.rb | |
echo 'Creating configuration files' | |
echo 'proxy_redirect off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
client_max_body_size 10m; | |
client_body_buffer_size 128k; | |
client_header_buffer_size 64k; | |
proxy_connect_timeout 90; | |
proxy_send_timeout 90; | |
proxy_read_timeout 90; | |
proxy_buffer_size 16k; | |
proxy_buffers 32 16k; | |
proxy_busy_buffers_size 64k;' > /etc/nginx/conf.d/proxy.conf | |
echo 'server { | |
listen 80; | |
server_name _; | |
access_log /var/log/httpd/elasticbeanstalk-access_log; | |
error_log /var/log/httpd/elasticbeanstalk-error_log; | |
#set the default location | |
location / { | |
proxy_pass http://127.0.0.1:8080/; | |
} | |
# make sure the hostmanager works | |
location /_hostmanager/ { | |
proxy_pass http://127.0.0.1:8999/; | |
} | |
}' > /etc/nginx/conf.d/beanstalk.conf | |
echo 'Making sure that nginx starts on startup' | |
/sbin/chkconfig nginx on | |
echo 'Removing Apache...no longer needed' | |
yum remove httpd | |
echo 'Done' |
same here, I can't find /opt/elasticbeanstalk/srv path anywhere.
would it be possible to make many sites this way on a single instance? eg: http://admin.myapp.com and http://frontend.myapp.com/ I need the frontendapp to pull resources from the admin app. Each are separately managed repos. I haven't found how I could deploy two apps code bases to one single instance. Any thoughts would be appreciated.
Could not find /opt/elasticbeanstalk/srv path too
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where are you finding this path /opt/elasticbeanstalk/srv
Its not in any beanstalk i have seen.
Thoughts?