Now I only found one issue:
After logging in, I can see my code, so no problem here. But when I try to run my app using RStudio, the Chrome page goes gray and in the console I can find the following error:
WebSocket connection to 'wss://mydomain.com/rstudio/p/b25d206d/websocket/' failed: Error during WebSocket handshake: Unexpected response code: 404
I tried to apply some solutions I found online but they didn't work. When I ran my shiny app directly in the browser by typing mydomain.com/shiny the app works fine, but it was also giving me the warning in the console about the websocket, so I changed my shiny-server config file, adding this new line:
disable_protocols websocket;
So now I don't have any error message in the console and mydomain.com/shiny continues to work fine.
But I wasn't able to fix this same websocket error message after trying to run the app in RStudio server.
In your proxy settings you have opened the port 8787 (which is the port that RStudio server uses) and not 3838 (that Shiny server uses, unless overriden).
I am more of a Nginx than Apache person, so I can not help you with the actual settings, but if I were you I would check the ports.
So Shiny Server (and RStudio Connect) can run protocols other than websockets for hosting Shiny applications. However, RStudio Server's implementation requires websockets in order to function.
Basically, the behavior you are seeing tells us: "websockets are not being propagated properly through the proxy."
The way that we do this in our guide is to ensure the appropriate modules are being loaded:
In any case, I think the two ProxyPass lines are a bit redundant, and one of them should be removed, depending on how you have things set up (i.e. is RStudio Server listening on HTTP or HTTPS):
And if I use your suggestion for the virtual host configuration, when I type mydomain.com/rstudio I'm redirected to the http version (and then if I click on the url and press enter again it redirects me to the https version).
So I logged in using the https version and after the login the url goes again automatically to the http version and I can see my code (this doesn't happen with the config I inserted in my first post. Using the other config the page is always using https), but when I click on "Run app" the websocket error remains the same.
Can you clarify if you are using HTTPS for RStudio? I.e. You have SSL from the browser to apache. Is RStudio listening SSL for traffic from apache to RStudio? It sounds like the current problem w/ HTTP vs. HTTPS is your ProxyRedirect is not being caught appropriately. Understanding the target architecture will definitely help make recommendations accordingly
I don't know if I understood your question, Cole..
How can I check if RStudio is listening?
What I tried to do (and it's finally working) is to use the SSL certificate I selected on AWS to always see the https version of mydomain.com/rstudio
Does that mean that RStudio is listening SSL? (based on the virtual host code I inserted in my first post, every time I type on chrome mydomain.com/rstudio it redirects automatically to https://www.mydomain.com/rstudio and I can safely log in).
Sorry, I didn't phrase my question super well. Is it possible that you can share your /etc/rstudio/rserver.conf file? That should tell me what I'm looking for.
If I use your suggestion, I'm redirected to the http version of the page when I type mydomain.com/rstudio and only if I click on the url and click enter again, then I'm redirected to the https page. And when I log in, my url changes to localhost:8787 and this is the page after logging in:
I know this is the configuration RStudio suggests, but unfortunately it didn't work for me. What worked was the configuration I pasted here in my first post. The only thing I'm not able to do is to run the app inside RStudio using https because of the websocket error.
It's worth noting that another possibility is that your AWS load balancer is never sending the X-Forwarded-Proto header, in which case you may have the wrong protocol specified in your TargetGroup or ELB setup. The protocol should be HTTP (not TCP):
I have only one more doubt. It's also about websockets but on shiny server: as you said, shiny works if we disable websockets (like I did to avoid the 400 error in Chrome console). But is this best way to fix the problem? Just add the disable_protocols websocket; line in my shiny server config and that's it?
If websockets are working for RSP now, you can implement the same type of setup for Shiny Server and websockets should work then! I would generally recommend that approach (i.e. get websockets working) over disabling websockets, because certain software / clients (i.e. shinyloadtest) are dependent on websockets.