2017-01-19 8 views
1

私はDjangoのバックエンドからフロントエンドへのプッシュメッセージが必要です。最後に私はこのTwisted + Djangoサーバーを見つけましたが、製品envではnginxを使用してDjangoへのプロキシ要求を行いました。ヘンドリックスとNginxを一緒に使うことはできますか?

「はい」の場合は、どのようにnginx.confを書きますか?

答えて

0

もちろん、他のWSGI/ASGIコンテナと同じように、nginxを使用してhendrixへのプロキシを渡すことができます。

This Questionにはこれを行うためのサンプル設定があります。

+0

、素晴らしい今日はsuccefullyプロキシ・ヘンドリックスを逆にnginxのを使用しよう〜 – gmaclinuxer

+0

素晴らしい、今日はsuccefullyプロキシ・ヘンドリックスを逆にnginxのを使用しよう〜 が、私は私の製品ENVでヘンドリックスを使用したい場合は、私はマルチdeplyする必要がありますヘンドリックスの労働者、しかし私はhendrixがsockファイルからの読み込みをサポートしていないことを発見し、hx start -w 4を試してみるとエラーが出ます – gmaclinuxer

0

は、私はここで、プロキシ・ヘンドリックスを逆に私のオリジナルのnginxの設定を変更しようと今日はいくつかのスニペットです:

upstream django { 
     server localhost:8000; 
    } 
    server { 
    listen 80; 
    server_name localhost; 

    location /static/ { 
      #root /var/www; 
      alias /var/www/static; 
    } 

    location/{ 
      proxy_pass http://django; 
      proxy_pass_header Server; 
      proxy_set_header Host $host; 
      proxy_redirect off; 
      proxy_set_header X-Real-IP $remote_addr; 
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
      proxy_http_version 1.1; 
      proxy_set_header Upgrade $http_upgrade; 
      proxy_set_header Connection "upgrade"; 
    } 
    } 

それから私は、nginxのを再起動し、ヘンドリックスを開始します。

--log ./test.logを開始HX

それが最終的に働いたが、私はいくつかの警告メッセージが見つかりました:へ*

のWebSocket接続は '...' に失敗しました:エラーのWebSocket ハンドシェーク中:「接続イオン」ヘッダー値がされていない '' アップグレード:キープアライブ socket.io.js:2371

を*

いくつかのGoogleのメッセージの後、私はnginxのバージョンしなければならない高い1.3.13を見つけたので、私は更新しますnginxを1.10.1(安定)に設定すると、警告メッセージは表示されなくなります。私の生産ENVでヘンドリックスを使用したい場合は

がしかし、マルチ・ヘンドリックス・労働者に必要なので、私は試してみてください。

[email protected]:/vagrant/hendrix_taste/hendrix/examples/django_hx_chatserver/example_app# hx start -w 2                                    
Adding media resource for URL 'static' at path '/vagrant/hendrix_taste/hendrix/examples/django_hx_chatserver/example_app/servedstatics'                           
... 
Adding media resource for URL 'static/admin' at path '/usr/local/lib/python2.7/dist- 
'/vagrant/hendrix_taste/hendrix/examples/django_hx_chatserver/example_app/chat/static/chat/js'                       
Ready and Listening on port 8000...                                                    
{0: 0, 1: 1, 2: 2, 4: 4}                                                       
{'main_web_tcp': 4}                                                        
Unhandled Error                                                         
Traceback (most recent call last):                                                    
    File "/usr/local/lib/python2.7/dist-packages/hendrix/deploy/base.py", line 180, in run                                       
    getattr(self, action)(fd)                                                     
    File "/usr/local/lib/python2.7/dist-packages/hendrix/deploy/base.py", line 226, in start                                      
    self.launchWorkers(pids)                                                      
    File "/usr/local/lib/python2.7/dist-packages/hendrix/deploy/base.py", line 265, in launchWorkers                                    
    DeployServerProtocol(args), 'hx', args, childFDs=self.childFDs, env=environ                                         
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 340, in spawnProcess                                   
    processProtocol, uid, gid, childFDs)                                                   
--- <exception caught here> ---                                                     
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/process.py", line 756, in __init__                                    
    self.proto.makeConnection(self)                                                    
exceptions.AttributeError: 'DeployServerProtocol' object has no attribute 'makeConnection'                                      

Unhandled Error                                                         
Traceback (most recent call last):                                                    
    File "/usr/local/lib/python2.7/dist-packages/hendrix/deploy/base.py", line 180, in run                                       
    getattr(self, action)(fd)                                                     
    File "/usr/local/lib/python2.7/dist-packages/hendrix/deploy/base.py", line 226, in start                                      
    self.launchWorkers(pids)                                                      
    File "/usr/local/lib/python2.7/dist-packages/hendrix/deploy/base.py", line 265, in launchWorkers                                    
    DeployServerProtocol(args), 'hx', args, childFDs=self.childFDs, env=environ                                         
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 340, in spawnProcess                                   
    processProtocol, uid, gid, childFDs)                                                   
--- <exception caught here> ---                                                     
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/process.py", line 756, in __init__                                    
    self.proto.makeConnection(self)                                                    
exceptions.AttributeError: 'DeployServerProtocol' object has no attribute 'makeConnection'                                      

Adding media resource for URL 'static' at path '/vagrant/hendrix_taste/hendrix/examples/django_hx_chatserver/example_app/servedstatics'                           
...                     
Ready and Listening on port 8000...                                                    
Unhandled error in Deferred:                                                      


Traceback (most recent call last):                                                    
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 317, in addCallback                                    
    callbackKeywords=kw)                                                       
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 306, in addCallbacks                                    
    self._runCallbacks()                                                       
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 588, in _runCallbacks                                   
    current.result = callback(current.result, *args, **kw)                                              
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1313, in execute                                     
    d = maybeDeferred(f, *args, **kwargs)                                                  
--- <exception caught here> ---                                                     
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 150, in maybeDeferred                                   
    result = f(*args, **kw)                                                      
exceptions.TypeError: _addSubprocess() takes exactly 4 arguments (5 given)                                          
Temporarily disabling observer <twisted.logger._filter.FilteringLogObserver object at 0x20bac50> due to exception: [Failure instance: Traceback: <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute '_formatter_parser'  
/usr/local/lib/python2.7/dist-packages/hendrix/deploy/base.py:283:addSubprocess                                         
/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py:707:__del__                                          
/usr/local/lib/python2.7/dist-packages/twisted/logger/_logger.py:178:failure                                          
/usr/local/lib/python2.7/dist-packages/twisted/logger/_logger.py:132:emit                                          
--- <exception caught here> ---                                                     
/usr/local/lib/python2.7/dist-packages/twisted/logger/_observer.py:131:__call__                                         
/usr/local/lib/python2.7/dist-packages/twisted/logger/_filter.py:131:__call__                                         
/usr/local/lib/python2.7/dist-packages/twisted/logger/_file.py:50:__call__                                          
/usr/local/lib/python2.7/dist-packages/twisted/logger/_json.py:245:<lambda>                                          
/usr/local/lib/python2.7/dist-packages/twisted/logger/_json.py:196:eventAsJSON                                         
/usr/local/lib/python2.7/dist-packages/twisted/logger/_flatten.py:87:flattenEvent                                        
/usr/lib/python2.7/string.py:621:parse                                                   
]                                                            

Traceback (most recent call last):                                                    
    File "/usr/local/lib/python2.7/dist-packages/hendrix/deploy/base.py", line 283, in addSubprocess                                    
    self._lock.run(self._addSubprocess, self, fds, name, factory)                                            
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 707, in __del__                                     
    debugInfo=debugInfo)                                                       
    File "/usr/local/lib/python2.7/dist-packages/twisted/logger/_logger.py", line 178, in failure                                     
    self.emit(level, format, log_failure=failure, **kwargs)                                              
    File "/usr/local/lib/python2.7/dist-packages/twisted/logger/_logger.py", line 132, in emit                                      
    self.observer(event)                                                       
--- <exception caught here> ---                                                     
    File "/usr/local/lib/python2.7/dist-packages/twisted/logger/_observer.py", line 131, in __call__                                    
    observer(event)                                                        
    File "/usr/local/lib/python2.7/dist-packages/twisted/logger/_filter.py", line 131, in __call__                                     
    self._observer(event)                                                      
    File "/usr/local/lib/python2.7/dist-packages/twisted/logger/_file.py", line 50, in __call__                                     
    text = self.formatEvent(event)                                                    
    File "/usr/local/lib/python2.7/dist-packages/twisted/logger/_json.py", line 245, in <lambda>                                     
    lambda event: u"{0}{1}\n".format(recordSeparator, eventAsJSON(event))                                          
    File "/usr/local/lib/python2.7/dist-packages/twisted/logger/_json.py", line 196, in eventAsJSON                                    
    flattenEvent(event)                                                       
    File "/usr/local/lib/python2.7/dist-packages/twisted/logger/_flatten.py", line 87, in flattenEvent                                    
    aFormatter.parse(event["log_format"])                                                  
    File "/usr/lib/python2.7/string.py", line 621, in parse                                              
    return format_string._formatter_parser()                                                  
exceptions.At 

私のPythonパッケージ:-w 2を開始HX、出力失敗 がフリーズPIPを

Warning: cannot find svn location for distribute==0.6.24dev-r0 
Automat==0.3.0 
Django==1.8.11 
GnuPGInterface==0.3.2 
Jinja2==2.9.4 
MarkupSafe==0.23 
PyYAML==3.12 
Twisted==16.0.0 
apt-xapian-index==0.44 
argh==0.26.2 
argparse==1.2.1 
attrs==16.3.0 
characteristic==14.3.0 
chardet==2.0.1 
command-not-found==0.2.44 
configobj==4.7.2 
constantly==15.1.0 
decorator==3.3.2 
## FIXME: could not find svn URL in dependency_links for this package: 
distribute==0.6.24dev-r0 
hendrix==2.0.2 
incremental==16.10.1 
ipython==0.12.1 
language-selector==0.1 
pathtools==0.1.2 
pexpect==2.3 
pyOpenSSL==16.2.0 
pyasn1==0.1.9 
pyasn1-modules==0.0.8 
pychalk==0.0.5 
python-apt==0.8.3ubuntu7.1 
python-debian==0.1.21ubuntu1 
service-identity==16.0.0 
simplegeneric==0.7 
six==1.10.0 
txsockjs==1.2.2 
ufw==0.31.1-1 
virtualenv==15.1.0 
watchdog==0.8.3 
wsgiref==0.1.2 
zope.interface==4.0.5 
関連する問題