Search code examples
amazon-ec2erlangyaws

Installing Yaws server on Ubuntu 12.04 (Using a cloud service)


I'm trying to get a Yaws web server working on a cloud service (Amazon AWS). I've compilled and installed a local copy on the server. My problem is that I can't get Yaws to run while running on either port 8000 or port 80.

I have the following configuration in yaws.conf:

   port = 8000
   listen = 0.0.0.0
   docroot = /home/ubuntu/yaws/www/test
   dir_listings = true

This produces the following successful launch/result:

Eshell V5.8.5 (abort with ^G)

=INFO REPORT==== 16-Sep-2012::17:21:06 === Yaws: Using config file /home/ubuntu/yaws.conf

=INFO REPORT==== 16-Sep-2012::17:21:06 === Ctlfile : /home/ubuntu/.yaws/yaws/default/CTL

=INFO REPORT==== 16-Sep-2012::17:21:06 === Yaws: Listening to 0.0.0.0:8000 for <3> virtual servers: - http://domU-12-31-39-0B-1A-F6:8000 under /home/ubuntu/yaws/www/trial -

=INFO REPORT==== 16-Sep-2012::17:21:06 === Yaws: Listening to 0.0.0.0:4443 for <1> virtual servers: -

When I try to access the the url (http://ec2-72-44-47-235.compute-1.amazonaws.com), it never connects. I've tried using paping to check if port 80 or 8000 is open(http://code.google.com/p/paping/) and I get a "Host can not be resolved" error, so obviously something isn't working.

I've also tried setting the yaws.conf so its at Port 80, appearing like this:

   port = 8000
   listen = 0.0.0.0
   docroot = /home/ubuntu/yaws/www/test
   dir_listings = true

and I get the following error:

=ERROR REPORT==== 16-Sep-2012::17:24:47 === Yaws: Failed to listen 0.0.0.0:80 : {error,eacces}

=ERROR REPORT==== 16-Sep-2012::17:24:47 === Can't listen to socket: {error,eacces} =ERROR REPORT==== 16-Sep-2012::17:24:47 === Top proc died, terminate gserv =ERROR REPORT==== 16-Sep-2012::17:24:47 === Top proc died, terminate gserv =INFO REPORT==== 16-Sep-2012::17:24:47 === application: yaws exited: {shutdown,{yaws_app,start,[normal,[]]}} type: permanent {"Kernel pid terminated",application_controller," {application_start_failure,yaws,>>>>>>{shutdown,>{yaws_app,start,[normal,[]]}}}"}

I've also opened up the port 80 using iptables. Running sudo iptables -L gives this output:

Chain INPUT (policy ACCEPT) target prot opt source destination
ACCEPT tcp -- ip-192-168-2-0.ec2.internal ip-192-168-2-16.ec2.internal tcp dpt:http ACCEPT tcp -- 0.0.0.0 anywhere tcp dpt:http ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED ACCEPT tcp -- anywhere anywhere tcp dpt:http ACCEPT tcp -- anywhere anywhere tcp dpt:http

Chain FORWARD (policy ACCEPT) target prot opt source destination

Chain OUTPUT (policy ACCEPT) target prot opt source destination

Thanks for the patience


Solution

  • Actually, I found the answer to why I couldn't get it to work, through this forum post (http://www.trapexit.org/forum/viewtopic.php?p=42923).

    It states:

    2a. I run yaws on 8080 and have nginx reverse proxying 
    from http://mydomain:80 to 8080. Yaws won't run as a 
    low-privilege user if you want it to listen on port 
    80.
    
    2b. nginx.conf needs the following directives: 
    server { 
    listen 80; 
    server_name yourdomain.com; 
    access_log /path/to/access/log.log 
    location / { 
    proxy_pass http://127.0.0.1:8080; 
    proxy_redirect default; 
    } 
    } 
    

    Basically, I installed nginx, and configured it to run as a proxy server.

    I have used the same solution in order to get a Chicago Boss framework to run, the only difference is that I have nginx proxy_pass set to >http://127.0.0:8001 since Chicago Boss runs on 8001 by default. Anyone know how this effects an erlang servers concurrency advantages if someone is using nginx as a proxy server, or it has no effect what so ever?