Nginx作为Lighttpd的代理

时间:2014-06-27 18:12:21

标签: php django nginx lighttpd

我尝试使用nginx + gunicorn的django服务器和用于php的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的示例。

对不起我可怕的英语:)

1 个答案:

答案 0 :(得分: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;  
    }
}