Shiny Server - Serve only folders with app.R - r

My shiny-server path has subfolders with files that should not be served. ie, it's like
/srv/shiny-server/
content_folder/
subfolder1/
file_that_should_not_be_served.csv
folder_that_should_not_be_served/
some_files_and_folders
inner_folder/
app.R
supporting_files
I need to serve http://localhost:3838/content_folder/subfolder1/inner_folder/ as shiny application, but need to throw some error (ideally notfound or unauthorized) when other folders/files are opened. eg, http://localhost:3838/content_folder/subfolder1/folder_that_should_not_be_served/ and http://localhost:3838/content_folder/subfolder1/file_that_should_not_be_served.csv should fail.
Is there a way to do this? I'm open to using proxy servers if that would help...

Related

Configuring Web Server in Google Cloud Compute Engine

I have a dash application in a compute engine instance that I'm looking to view in my browser. HTTP and HTTPS traffic is enabled and the instance has a static IP address. The apache server works and when I first ran an application, the default index page located at /var/www/html showed up at the browser address http://EXTENAL_IP_OF_VM_INSTANCE
From what I've seen elsewhere, web application files tend to be stored in the /var/www directory and the index.html file is present as the default page. However I have a single app.py file that I want to run which is located in the /home/user directory, so not in any particular web directory.
I run the app by entering python3 app.py and it does run:
Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
However, going to the instance's external IP address (34.89.0.xx) in my browser doesn't show the app, instead it shows text from an old 'hello world' application I made previously, that I thought I had deleted but is still showing up.
Part of the server configuration file apache2.conf is below:
The sites-available folder contains two files, 000-default.conf and default-ssl.conf, both with /var/www/html as the DocumentRoot. 000-default.conf is also in the sites-available folder, and is the only file there.
I tried changing the DocumentRoot in these files to /home/user where the app.py file is which didn't work, then I tried moving the file to the web directory /var/www which didn't work either.
Does anyone have any suggestions on how to fix this so that I can see my application in the browser?

R Shiny: How to output `getwd()`

Is there something like a working directory when deploying an app to shinyapps.io?
In my app directory I keep ui.r and server.r, as well as another directory for additional scripts (engine). What would be the path to that directory when the app is deployed on shinyapps.io?

Nginx fails to create directories on Windows 10 with error: nginx: CreateFile()...failed

I need to find a way/setting to allow Nginx to run a .bat file that will create directories and files via a WINDOWS service; my OS is Windows 10.
Currently, our windows service fails to create directories and files with the following:
CreateFile()
"C:\someForlderName\build\distribution.\nginx/logs/error.log" failed
(3: The system cannot find the path specified)
Somehow Nginx doesn't have enough permissions to perform write-access operations like creating directories such as /logs/ and /temp/ within the /Nginx/ directory.
Anybody ran into this problem before?
I was facing the same problem, sharing the thing that worked for me.
Nginx is showing this error because... nginx didn't find the error.log file..
For that,
Go to you nginx folder where other folders like conf, docs, html etc are their as.
Create folder name logs, and in that folder create a file name error.logas.
see the right way in picture..
If your Nginx is at D:\nginx\nginx.exe, execute this to start nginx
D:\nginx\nginx.exe -c D:\nginx\conf\nginx.conf -p D:\nginx\
For Nginx on Windows, you need to execute nginx server related command from respective home directory where nginx configuration file is located.

R shiny: Retrieve home directory of a shiny app

Is there a function or a way to retrieve the path of root home directory of a shiny app?
The shiny app I run creates multiple directories and changes working directory. But at point in the app, I need to jump to the home directory. getwd() won't work unless I run it first and save it as a variable or something.
I am thinking of something like the below command used to read a file from a package home directory on any platform without knowing the actual path.
#get root dir
system.file()
# read a file from the root dir of a package
a <- system.file("bla",package="foo")
The approach has to work locally, on shiny-server and shinyapps.io. (In situations where I cannot set the path manually).

Seeking help setting up a micro instance on AWS EC2 for a simple "hello world" app

I'm trying to get a working app on a micro instance on amazon ec2.
I've been using the ami (ami-e2a3358b) I found from a blog post at http://trestletechnology.net/2013/02/deploying-shiny-server-on-amazon-ec2/
I've been learning about using EC2 but it is new to me. I'm using putty and winSCV to connect to the machine.
Now I think I'm at the stage where I want to make a config file and put my app in a ShinyApps folder. I've read over config.html in /shiny-server but I am having some trouble putting all the pieces together. I've also looked at http://rstudio.github.io/shiny-server/latest/ but I haven't figured it all out.
I just want to have a single ShinyApps folder I can put my apps in with a shiny-server.conf file that will recognize where that folder is.
What config file do I need to put in /shiny-server directory? Where do want to put my ShinyApps folder for this config file? And what is the final address (and port?) that I want to put in the url bar to get to the app?
Thanks for any responses. If I haven't been clear its from ignorance so help me out and ask me a question if I need to elaborate.
I added a conf file at /etc/shiny-server/shiny-server.conf
john#ubuntu:~$ more /etc/shiny-server/shiny-server.conf
# Define the user we should use when spawning R Shiny processes
run_as shiny;
# Define a top-level server which will listen on a port
server {
# Instruct this server to listen on port 3838
#listen 3838 127.0.0.1;
listen 3838;
location /userApps {
user_apps;
directory_index on;
}
}
Then for example user john would just need to have a Shinyapps directory in their home directory. This was the case for [2014-03-18 17:43:01.113] [INFO] shiny-server - Shiny Server v0.4.0.15 (Node.js v0.10.21) maybe different now.

Resources