我应该如何在一台服务器上托管多个 Pylons 网站?

发布于 2024-09-26 21:06:55 字数 311 浏览 2 评论 0原文

我目前在我的服务器上运行一个 Pylons 网站,该网站使用 nginx 作为 Paster 的代理进行设置。在不久的将来,我计划在同一服务器上托管另一个 Pylons 站点。

如果我采用相同的路线并使用 nginx+Paster,则意味着在不同端口上运行两个 Paster 实例,然后使用一台 nginx 服务器作为代理转发器到 127.0.0.1:808(1|2)。

让两个粘贴服务器为两个不同的站点运行似乎是一个坏主意。如果我的服务器上有 10 个 Pylons 站点,则意味着有 10 个 Paster 服务器实例正在运行...

有什么更好的解决方案?

I currently have one Pylons website running on my server that is setup using nginx as a proxy to Paster. In the near future, I plan to host another Pylons site on the same server.

If I were to go the same route and use nginx+Paster, it would mean running two paster instances on different ports and then using the one nginx server as a proxy forwarder to 127.0.0.1:808(1|2).

It seems like a bad idea to have two paster servers running for two different sites. If I were to have 10 Pylons sites on the server, it would mean 10 Paster server instances running...

What's a better solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流心雨 2024-10-03 21:06:55

我认为运行少量的 Paster 实例并没有什么问题,但你应该考虑使用 FastCGI(或 wsgi)和虚拟主机,因为它更适合“生产环境”。
FastCGI 示例:

pid         /var/run/nginx.pid;
user            www;
worker_processes    1;

events {
    worker_connections  1024;
}

http {
    include     /etc/mime.types;
    default_type    application/octet-stream;

    sendfile        on;
    gzip            on;
    keepalive_timeout   65;

    # First site
    server {
        listen *:443;
        server_name     first.example.com;

        ssl         on;
        ssl_certificate     /etc/www/cert.pem;
        ssl_certificate_key /etc/www/key.pem;
        ssl_session_timeout 5m;
        ssl_protocols       SSLv3 TLSv1;

        location / {
            fastcgi_pass            127.0.0.1:9000;
            fastcgi_param PATH_INFO     $fastcgi_script_name;
            fastcgi_param REQUEST_METHOD    $request_method;
            fastcgi_param QUERY_STRING  $query_string;
            fastcgi_param CONTENT_TYPE  $content_type;
            fastcgi_param CONTENT_LENGTH    $content_length;
            fastcgi_param REMOTE_ADDR   $remote_addr;
            fastcgi_param SERVER_ADDR   $server_addr;
            fastcgi_param SERVER_PORT   $server_port;
            fastcgi_param SERVER_NAME   $server_name;
            fastcgi_param SERVER_PROTOCOL   $server_protocol;
            fastcgi_param HTTPS     on;
            fastcgi_pass_header     Authorization;
            fastcgi_intercept_errors    off;
        }
        access_log  /var/log/first.access.log main;
        error_log   /var/log/first.error.log;
    }
    # Second site
    server {
        listen *:443;
        server_name     second.example.com;

        ssl            on;
        ssl_certificate        /etc/www/cert1.pem;
        ssl_certificate_key    /etc/www/key1.pem;
        ssl_session_timeout    5m;
        ssl_protocols        SSLv3 TLSv1;

        location / {
            fastcgi_pass            127.0.0.1:9001;
            fastcgi_param PATH_INFO        $fastcgi_script_name;
            fastcgi_param REQUEST_METHOD    $request_method;
            fastcgi_param QUERY_STRING    $query_string;
            fastcgi_param CONTENT_TYPE    $content_type;
            fastcgi_param CONTENT_LENGTH    $content_length;
            fastcgi_param REMOTE_ADDR    $remote_addr;
            fastcgi_param SERVER_ADDR    $server_addr;
            fastcgi_param SERVER_PORT    $server_port;
            fastcgi_param SERVER_NAME    $server_name;
            fastcgi_param SERVER_PROTOCOL    $server_protocol;
            fastcgi_param HTTPS        on;
            fastcgi_pass_header        Authorization;
            fastcgi_intercept_errors    off;
        }
        access_log    /var/log/second.access.log main;
        error_log    /var/log/second.error.log;
    }
}

现在,您必须站点:

first.example.com -> localhost:9000
second.example.com -> localhost:9001

您还可以设置 IP 来“监听”,例如:

listen 192.168.1.1:443;
listen 192.168.1.2:443;

这样您就可以使用 IP 而不是 DNS 名称。

对于 Pylons 应用程序,您应该将配置更改为 FastCGI:

[server:main]
use = egg:Flup#fcgi_thread
host = 127.0.0.1
port = 9000

对于第一个主机,对于第二个主机:

[server:main]
use = egg:Flup#fcgi_thread
host = 127.0.0.1
port = 9001

希望这会有所帮助。

I think there is nothing wrong with running few paster instances, but you should consider using FastCGI (or wsgi) and Virtual Hosts, because it's more suitable for "production environment".
Example with FastCGI:

pid         /var/run/nginx.pid;
user            www;
worker_processes    1;

events {
    worker_connections  1024;
}

http {
    include     /etc/mime.types;
    default_type    application/octet-stream;

    sendfile        on;
    gzip            on;
    keepalive_timeout   65;

    # First site
    server {
        listen *:443;
        server_name     first.example.com;

        ssl         on;
        ssl_certificate     /etc/www/cert.pem;
        ssl_certificate_key /etc/www/key.pem;
        ssl_session_timeout 5m;
        ssl_protocols       SSLv3 TLSv1;

        location / {
            fastcgi_pass            127.0.0.1:9000;
            fastcgi_param PATH_INFO     $fastcgi_script_name;
            fastcgi_param REQUEST_METHOD    $request_method;
            fastcgi_param QUERY_STRING  $query_string;
            fastcgi_param CONTENT_TYPE  $content_type;
            fastcgi_param CONTENT_LENGTH    $content_length;
            fastcgi_param REMOTE_ADDR   $remote_addr;
            fastcgi_param SERVER_ADDR   $server_addr;
            fastcgi_param SERVER_PORT   $server_port;
            fastcgi_param SERVER_NAME   $server_name;
            fastcgi_param SERVER_PROTOCOL   $server_protocol;
            fastcgi_param HTTPS     on;
            fastcgi_pass_header     Authorization;
            fastcgi_intercept_errors    off;
        }
        access_log  /var/log/first.access.log main;
        error_log   /var/log/first.error.log;
    }
    # Second site
    server {
        listen *:443;
        server_name     second.example.com;

        ssl            on;
        ssl_certificate        /etc/www/cert1.pem;
        ssl_certificate_key    /etc/www/key1.pem;
        ssl_session_timeout    5m;
        ssl_protocols        SSLv3 TLSv1;

        location / {
            fastcgi_pass            127.0.0.1:9001;
            fastcgi_param PATH_INFO        $fastcgi_script_name;
            fastcgi_param REQUEST_METHOD    $request_method;
            fastcgi_param QUERY_STRING    $query_string;
            fastcgi_param CONTENT_TYPE    $content_type;
            fastcgi_param CONTENT_LENGTH    $content_length;
            fastcgi_param REMOTE_ADDR    $remote_addr;
            fastcgi_param SERVER_ADDR    $server_addr;
            fastcgi_param SERVER_PORT    $server_port;
            fastcgi_param SERVER_NAME    $server_name;
            fastcgi_param SERVER_PROTOCOL    $server_protocol;
            fastcgi_param HTTPS        on;
            fastcgi_pass_header        Authorization;
            fastcgi_intercept_errors    off;
        }
        access_log    /var/log/second.access.log main;
        error_log    /var/log/second.error.log;
    }
}

Now, you have to sites:

first.example.com -> localhost:9000
second.example.com -> localhost:9001

You can also set IP in for "listen", e.g.:

listen 192.168.1.1:443;
listen 192.168.1.2:443;

so you are able to use IP instead of DNS name.

For Pylons app you should change configuration to FastCGI:

[server:main]
use = egg:Flup#fcgi_thread
host = 127.0.0.1
port = 9000

for first host, and for second:

[server:main]
use = egg:Flup#fcgi_thread
host = 127.0.0.1
port = 9001

Hope this helps.

年少掌心 2024-10-03 21:06:55

您可以使用单个粘贴器实例来启动多个应用程序。下面的链接有一篇很好的文章,解释了如何使用 Paster 的 urlmap 来实现这一点。

http://countergram.com/pylons-virtual-host-multiple-domain

You can use a single paster instance to launch multiple applications. The link below has a nice article explaining how to use paster's urlmap to achieve this.

http://countergram.com/pylons-virtual-host-multiple-domain

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文