我試圖在HP雲上創建一個devpi鏡像,該鏡像將通過nginx訪問,即 - nginx偵聽端口80並用作devpi的代理即在同一臺機器上使用端口4040。將nginx配置爲代理與HP-cloud上的devpi鏡像一起工作
我已經爲hp-cloud中的所有端口(入站和出站)打開了HP-cloud安全組(僅用於開始,稍後我將對其進行更改),並啓動了Ubuntu 14實例。
我已經爲我創建的實例分配了一個公有IP。
我已經使用pip安裝了devpi-server,而使用apt-get安裝了nginx。
我按照devpi的tutuorial頁面here上的說明操作:
ran devpi-server --port 4040 --gen-config
,並將在nginx-devpi.conf中創建的內容複製到nginx.conf中。
然後,我使用devpi-server --port 4040 --start
啓動了服務器。
使用sudo nginx
開始nginx。
我的問題如下: 當我正在SSH上運行nginx和devpi的hp-instance,並執行pip install -i http://<public-ip>:80/root/pypi/ simplejson
它成功了。
但是,當我從運行相同的命令,我的筆記本電腦我得到
Downloading/unpacking simplejson
Cannot fetch index base URL http://<public-ip>:80/root/pypi/
http://<public-ip>:80/root/pypi/simplejson/ uses an insecure transport scheme (http). Consider using https if <public-ip>: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
我想這可能是安全/網絡問題,但我認爲這並非如此,因爲curl http://<public-ip>:80
返回時,我從我的筆記本電腦,並從HP實例執行它同樣的事情:
{
"type": "list:userconfig",
"result": {
"root": {
"username": "root",
"indexes": {
"pypi": {
"type": "mirror",
"bases": [],
"volatile": false
}
}
}
}
}
我也試圖在HP雲啓動另一個實例並執行pip install -i http://<public-ip>:80/root/pypi/ simplejson
,但我得到了同樣的犯錯或者像我的筆記本電腦。
我不明白這兩種情況有什麼區別,如果有人會爲這種情況提供解決方案,或者任何想法可能是問題,我會很高興。
我nginx.conf
文件:
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/*;
}
編輯: 我曾嘗試使用devpi-client
從我的筆記本電腦,當我從我的筆記本電腦執行devpi use http://<public-ip>:80
我得到如下:
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