2014-06-27 92 views
0

我嘗試使用nginx + gunicorn和lighttpd for php來創建django服務器。我應該如何配置nginx來代理我的子域到lighttpd?Nginx作爲Lighttpd的代理

例如。

myawesomesite.com => dajango網站(工作)

cloud.myawesomesite.com => lighttpd的PHP服務器(不工作)

我其實是想

server { 
    listen 80; 
    server_name cloud.awesome.eu; 
location/{ 
     proxy_pass http://127.0.0.1:8080; 
     #root /var/www; 
    } 
} 

而對於ssl

server { 
    listen 443 ssl; 
    #ssl on; 
    server_name cloud.awesome.eu; 
    #root /var/www; 
    #ssl_certificate /etc/nginx/ssl/server.crt; 
    #ssl_certificate_key /etc/nginx/ssl/server.key; 
    index index.php; 
    try_files $uri $uri/ /index.php?q=$uri&$args; 
    location/{ 
     proxy_pass http://127.0.0.1:8080; 
     proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; 
     proxy_redirect off; 
     proxy_buffering off; 
     proxy_set_header  Host   cloud.awesome.com; 
     proxy_set_header  X-Real-IP  $remote_addr; 
     proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for; 
    } 

} 

所有配置示例是針對nginx + apache的。我沒有找到nginx的例子+ lighttpd。

對不起,我很可怕的英語:)

回答

0

現在所有爲我工作!

server { 
    listen 80; 
    server_name cloud..eu; #change this 
location/{ 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $remote_addr; 
     proxy_set_header Host $host; 
     proxy_pass http://127.0.0.1:8080; 
     #root /var/www; 
    } 
} 
server { 
    listen 443; 
    ssl on; 
    server_name cloud..eu; #change this 
    #root /var/www; #change this 
    ssl_certificate /etc/nginx/ssl/server.crt; 
    ssl_certificate_key /etc/nginx/ssl/server.key; 
    location/{ 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $host; 
    proxy_set_header  X-Forwarded-Proto $scheme; 
    add_header    Front-End-Https on; 
    proxy_pass http://127.0.0.1:8080; 
    proxy_redirect off; 
    } 
}