M
M
Mikhail Smykov2015-09-12 22:52:25
Python
Mikhail Smykov, 2015-09-12 22:52:25

Why doesn't uploading files work?

Hello. I was given a very huge system of python scripts, which forms a game designer in the browser. My goal is to put it on hosting at any cost. I have already overcome many mistakes. There are only two problems left: confirming wmid (another story) and working with the repository. Ooooh.... How I wish it were simple... There are configs like this:
/etc/nginx/nginx.conf

user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#gzip on;
include /etc/nginx/sites/*;
}

/etc/nginx/sites/default
include "/etc/nginx/upstreams.conf";
# everything is fine there
server {
listen 0.0.0.0:80;
server_name www.domain.ru domain.ru;
charset off;
root /home/mg/static;
client_max_body_size 10m;
location ~ ^/st/([0-9-]+/|) {
root /home/mg/static/;
rewrite ^/st/([0-9-]+/|)(.+)$ /$2 break;
access_log /var/log/nginx/mmoconstructor-static.log combined;
expires 3M;
}
location ~ ^/st-mg/([0-9-]+/|) {
root /home/mg/static/;
rewrite ^/st-mg/([0-9-]+/|)(.+)$ /$2 break;
access_log /var/log/nginx/mmoconstructor-static.log combined;
expires 3M;
}
location = /favicon.ico {
root /home/mg/static/;
access_log /var/log/nginx/mmoconstructor-static.log combined;
expires 3M;
}
location /rpl {
proxy_pass http://localhost:8088;
proxy_read_timeout 200;
access_log /var/log/nginx/mmoconstructor-realplexor.log combine$
}
location / {
proxy_pass http://metagam;
proxy_set_header X-Real-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 200;
access_log /var/log/nginx/mmoconstructor.log combined;
}
}
server {
listen 0.0.0.0:80;
server_name storage.domain.ru;
client_max_body_size 20m;
location / {
root /home/webdav;
client_body_temp_path /tmp;
dav_methods PUT DELETE MKCOL COPY MOVE;
create_full_put_path on;
dav_access user:rw group:rw all:r;
location ~ \.(html|htm)$ {
allow 127.0.0.1;
allow 10.0.0.0/8;
deny all;
}
}
}

As a result, the site and file storage should work, to which the following rights are given:
chown -R www-data.www-data /home/webdav (folder with storage)
As a result, when uploading any files, everything should be fine, but:
Traceback (most recent call last):
File "/home/mg/mg/core/web.py", line 493, in deliver_request
res = res()
File "/home/mg/mg/core/web.py", line 486, in
res = lambda: app.hooks.call("%s-%s.%s" % (self.hook_prefix, group, hook), check_priv=True)
File "/home/mg/mg/core/ applications.py", line 158, in call
res = handler(*args, **kwargs)
File "/home/mg/mg/socio/__init__.py", line 2357, in ext_settings
settings.set("avatar", self.call("cluster.static_upload", "avatars", ext, content_type, im_data))
File "/home/mg/mg/core/applications.py", line 245, in call
return self.app().hooks .call(*args,**kwargs)
File "/home/mg/mg/core/applications.py", line 158, in call
res = handler(*args, **kwargs)
File "/home/mg/mg/core/cluster.py", line 355, in static_upload
uri, url, host, id = self.upload(subdir, ext, content_type, data, filename=filename)
File "/home/mg/mg/core/cluster.py", line 308, in upload
cnn.connect((str(host), 80))
File "/usr/lib/python2.6 /concurrence/http/client.py", line 55, in connect
self._stream = BufferedStream(Connector.connect(endpoint), read_buffer_size = 1024 * 8, write_buffer_size = 1024 * 4)
File "/usr/lib/python2.6 /concurrence/io/__init__.py", line 38, in connect
return Socket.connect(endpoint, TIMEOUT_CURRENT)
File "/usr/lib/python2.6/concurrence/io/socket.py", line 91,in connect
socket._connect(addr, timeout)
File "/usr/lib/python2.6/concurrence/io/socket.py", line 169, in _connect
err = self.socket.connect_ex(addr)
gaierror: [Errno -5] No address associated with hostname

Tell me, please, what's wrong? There is definitely no error in the scripts. A complete copy of the version that was running on another server.
Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Smykov, 2015-09-14
@Chronosms

The problem was solved as follows:
In /etc/nginx/nginx.conf, the first line usually starts with the user. It should be named with the same name as the one who is given ownership of the folder in Linux.

I
Igor, 2015-09-13
@merryjane

gaierror: [Errno -5] No address associated with hostname

And server_name storage.domain.ru will definitely resolve to some ip-address? Do not forget to register it at least in /etc/hosts of the machine from where you are trying to upload files?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question