Search code examples
rshiny-servershiny

r shiny server is running, but the app is not working


We have built shiny-server on linux ubuntu, I check the status and the shiny-server.conf and both seems to be okay but not able to run the app, please see as below: 1. The shiny-server status:

  root@ubuntu:~# sudo status shiny-server
  shiny-server start/running, process 43150
  1. The server.conf

    # Instruct Shiny Server to run applications as the user "shiny"
    run_as shiny;
    
    # Define a server that listens on port 3838
    server {
      listen 3838;
    
      # Define a location at the base URL
      location / {
    
        # Host the directory of Shiny Apps stored in this directory
        site_dir /srv/shiny-server;
    
        # Log all Shiny output to files in this directory
        log_dir /var/log/shiny-server;
    
        # When a user visits the base URL rather than a particular application,
        # an index of the applications available in this directory will be shown.
        directory_index on;
      }
    }
    

However, when I put the server.R and UI.R files under srv/shiny-server and then run the URL, it is in vain and shows "Not found".

 http://<my_server>:3838/<app_name>

Solution

  • Below code shows an allappfolders created, under which you can create various apps like app1, app2..etc.

    Below will display all apps under

    http://<my_server>:3838/allappfolders
    

    Below app1 will load the ui.R and server.R

    http://<my_server>:3838/allappfolders/app1
    

    Full conf. code below:

    # Instruct Shiny Server to run applications as the user "shiny"
    run_as shiny;
    
    # Define a server that listens on port 3838
    server {
      listen 3838;
    
        location /users {
          run_as :HOME_USER:;
          user_dirs;
        }
    
        # Define a location at the base URL
        location /allappfolders {
            run_as shiny;
    
            # Host the directory of Shiny Apps stored in this directory
            site_dir /opt/shiny-server/allappfolders;
    
            # Log all Shiny output to files in this directory
            log_dir /var/log/shiny-server/allappfolders;
    
            # When a user visits the base URL rather than a particular application,
            # an index of the applications available in this directory will be shown.
            directory_index on;
        };
    
        # Define a location at the base URL
        location /app1 {
    
            # Host the directory of Shiny Apps stored in this directory
            app_dir /opt/shiny-server/allappfolders/app1;
    
            # Log all Shiny output to files in this directory
            log_dir /var/log/shiny-server/app1;
    
            # When a user visits the base URL rather than a particular application,
            # an index of the applications available in this directory will be shown.
            directory_index off;
        };
    
        # Define a location at the base URL
        location /app2 {
    
            # Host the directory of Shiny Apps stored in this directory
            app_dir /opt/shiny-server/allappfolders/app2;
    
            # Log all Shiny output to files in this directory
            log_dir /var/log/shiny-server/app2;
    
            # When a user visits the base URL rather than a particular application,
            # an index of the applications available in this directory will be shown.
            directory_index off;
        };
    
    }