title: configuring nginx as proxy to work with devpi mirror on HP-cloud
body: <p>I'm trying to create a <a href="http://doc.devpi.net/latest/" rel="nofollow">devpi</a> mirror on HP-cloud that will be accessed via nginx, i.e - nginx listens to port 80 and used as a proxy to devpi that is using port 4040 on the same machine.</p>
  
  <p>I have configured an HP-cloud security group that is opened for all ports (inbound and outbound) in hp-cloud (just for the beginning, I'll change it later of-course), and started an ubuntu 14 instance.<br>
  I have allocated a public IP to the instance that I have created.<br>
  I have installed devpi-server using pip, and nginx using apt-get.<br>
  I have followed the instructions on devpi's tutuorial page <a href="http://doc.devpi.net/latest/quickstart-server.html#quickstart-server" rel="nofollow">here</a>:<br>
  ran <code>devpi-server --port 4040 --gen-config</code>, and copied the contents that was created in nginx-devpi.conf into nginx.conf.<br>
  Then, I have started the server using <code>devpi-server --port 4040 --start</code>.<br>
  Started nginx using <code>sudo nginx</code>.  </p>
  
  <p>My problem is as follows:
  When I'm SSHing to the hp-instance on which the nginx and devpi are running, and executing <code>pip install -i http://&lt;public-ip&gt;:80/root/pypi/ simplejson</code> it succeeded.</p>
  
  <p>But, when I'm running the same command from <strong>my laptop</strong> I get</p>
  
  <pre><code>Downloading/unpacking simplejson
    Cannot fetch index base URL http://&lt;public-ip&gt;:80/root/pypi/
    http://&lt;public-ip&gt;:80/root/pypi/simplejson/ uses an insecure transport scheme (http). Consider using https if &lt;public-ip&gt;:80 has it available
    Could not find any downloads that satisfy the requirement simplejson
  Cleaning up...
  No distributions at all found for simplejson
  Storing debug log for failure in /home/hagai/.pip/pip.log
  </code></pre>
  
  <p>I thought it might be security/network issue, but I think that this is not the case, because <code>curl http://&lt;public-ip&gt;:80</code> returns the same thing when I'm executing it from my laptop and from the HP instance:</p>
  
  <pre><code>{
    "type": "list:userconfig", 
    "result": {
      "root": {
        "username": "root", 
        "indexes": {
          "pypi": {
            "type": "mirror", 
            "bases": [], 
            "volatile": false
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>I have also tried to start another instance in HP-cloud and execute <code>pip install -i http://&lt;public-ip&gt;:80/root/pypi/ simplejson</code>, but I got the same error as in my laptop.</p>
  
  <p>I can't understand what is the difference between these two cases, and I'd be happy if someone would have a solution for this case, or any idea what might be the problem.  </p>
  
  <p>My <code>nginx.conf</code> file:  </p>
  
  <pre><code>user www-data;
  worker_processes 4;
  pid /run/nginx.pid;
  
      events {
          worker_connections 768;
          # multi_accept on;
      }
  
      http {
  
          server {
              server_name localhost;   
              listen 80;
              gzip             on;
              gzip_min_length  2000;
              gzip_proxied     any;
              #gzip_types       text/html application/json; 
  
              proxy_read_timeout 60s;
              client_max_body_size 64M;
  
              # set to where your devpi-server state is on the filesystem
              root /home/ubuntu/.devpi/server;  
  
              # try serving static files directly
              location ~ /\+f/ {
                  error_page 418 = @proxy_to_app;
                  if ($request_method != GET) {
                      return 418; 
                  }
                  try_files /+files$uri @proxy_to_app;
              }
              # try serving docs directly
              location ~ /\+doc/ {
                  try_files $uri @proxy_to_app;
              }
              location / {
                  error_page 418 = @proxy_to_app;
                  return 418;
              }
              location @proxy_to_app {
                  proxy_pass http://localhost:4040;
                  #dynamic: proxy_set_header X-outside-url $scheme://$host:$server_port;
                  proxy_set_header  X-outside-url http://localhost:80;
                  proxy_set_header  X-Real-IP $remote_addr;
              }   
          } 
  
          ##
          # Basic Settings
          ##
  
          sendfile on;
          tcp_nopush on;
          tcp_nodelay on;
          keepalive_timeout 65;
          types_hash_max_size 2048;
          # server_tokens off;
  
          # server_names_hash_bucket_size 64;
          # server_name_in_redirect off;
  
          include /etc/nginx/mime.types;
          default_type application/octet-stream;
  
          ##
          # Logging Settings
          ##
  
          access_log /var/log/nginx/access.log;
          error_log /var/log/nginx/error.log;
  
          ##
          # Gzip Settings
          ##
  
          gzip on;
          gzip_disable "msie6";
  
          #passenger_root /usr;
          #passenger_ruby /usr/bin/ruby;
  
          ##
          # Virtual Host Configs
          ##
  
          include /etc/nginx/conf.d/*.conf;
          #include /etc/nginx/sites-enabled/*;
      }
  </code></pre>
  
  <p><strong>edit:</strong>
  I have tried to use <code>devpi-client</code> from my laptop, and when I've executed <code>devpi use http://&lt;public-ip&gt;:80</code> from <strong>my laptop</strong> I get the following:</p>
  
  <pre><code>using server: http://localhost/ (not logged in)
  no current index: type 'devpi use -l' to discover indices
  ~/.pydistutils.cfg     : no config file exists
  ~/.pip/pip.conf        : no config file exists
  ~/.buildout/default.cfg: no config file exists
  always-set-cfg: no
  </code></pre>