Passenger sub uri's

时光总嘲笑我的痴心妄想 提交于 2020-02-05 14:56:24

问题


The Phusion Passenger instructions are great in most regards. They have far better-than-average install guides on setting up NGINX, the passenger app, testing python, and so forth. The instructions on setting up several separate apps on a single server are, well, deficient. The main reason I adopted Passenger is the ability to host several apps.

I followed the Phusion Passenger instructions for setting up NGINX server with a sub URI (https://www.phusionpassenger.com/library/deploy/nginx/deploy/python/). I thought this would allow me to run separate apps with different sub folders. I have several python applications in /var/www, like so:

/var/www/dashboard
/var/www/peniso

I have a Python virtual environment for each one, in the separate subfolders venv. Each one works individually. But how to make all available at once? The problem I see is that no matter which sub URI is used, the same app runs.

Here's what I tried in my /etc/nginx/sites-enable/dashboard.conf file:

server {
    listen 80;
    server_name testapp.myexample.com;

    # Tell Nginx and Passenger where your app's 'public' directory is
    root /var/www/dashboard/public;

    passenger_app_type wsgi;
    passenger_startup_file passenger_wsgi.py;

    # Turn on Passenger
    passenger_enabled on;
    passenger_python /var/www/dashboard/venv/bin/python3.7;

    location ~ ^/mydash(/.*|$) {
        alias /var/www/dashboard/public$1;
        passenger_base_uri /mydash;
        passenger_app_root /var/www/dashboard;
        passenger_document_root /var/www/dashboard/public;
        passenger_enabled on;
        passenger_python /var/www/dashboard/venv/bin/python3.7;
   }


   location ~ ^/efergy(/.*|$) {
        alias /var/www/peniso/public$1;
        passenger_base_uri /efergy;
        passenger_app_root /var/www/peniso;
        passenger_document_root /var/www/peniso/public;
        passenger_enabled on;
        passenger_app_env development;
        passenger_python /var/www/peniso/venv/bin/python3.7;
   }
}

I browse http://testapp.myexample.com/mydash or http://testapp.myexample.com/efergy I see is the same app showing. In the top part, before the sub-sections, I can replace "dashboard" with "peniso" and it changes which 1 app runs. I've flipped the ordering of the folders, also changed the root from one to the other. Still only one app seems to be available.

How do you configure Passenger to work with several different apps?

Eventually, I need to host some Python and some Node.js apps, once I understand how to get the directories under /var/www to work right.

来源:https://stackoverflow.com/questions/59954886/passenger-sub-uris

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!