In step 3, configuring server block: is your_server_ip
an actual IP address, domain name, or localhost?
I have the following, but have tried ip address and local host. get 504 error code:
root /var/www/data-dancer.com;
index index.html;
server_name data-dancer.com www.data-dancer.com;
location / {
proxy_pass http://data-dancer.com:3838;
proxy_redirect http://data-dancer.com:3838 https://$host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 20d;
}
listen 443 ssl; # managed by Certbot
listen [::]:443 ssl ipv6only=on; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/data-dancer.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/data-dancer.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.data-dancer.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = data-dancer.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name data-dancer.com www.data-dancer.com;
return 404; # managed by Certbot
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Heya,
The issue is in your proxy_pass
configuration. You’re using data-dancer.com:3838
, but Shiny Server runs locally on your server, so you should be proxying to localhost
or 127.0.0.1
, not your domain name.
Here’s the corrected configuration:
server {
root /var/www/data-dancer.com;
index index.html;
server_name data-dancer.com www.data-dancer.com;
location / {
proxy_pass http://127.0.0.1:3838;
proxy_redirect http://127.0.0.1:3838/ $scheme://$host/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 20d;
proxy_buffering off;
}
listen 443 ssl; # managed by Certbot
listen [::]:443 ssl ipv6only=on; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/data-dancer.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/data-dancer.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.data-dancer.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = data-dancer.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name data-dancer.com www.data-dancer.com;
return 404; # managed by Certbot
}
proxy_pass
: From http://data-dancer.com:3838
to http://127.0.0.1:3838
proxy_redirect
: Updated to properly handle redirectsHost
, X-Real-IP
, X-Forwarded-For
, and X-Forwarded-Proto
proxy_buffering off
: Better for Shiny apps with real-time updatesAdd this to your main nginx configuration (usually in /etc/nginx/nginx.conf
) in the http
block:
http {
# ... other configuration ...
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# ... rest of configuration ...
}
Before testing, make sure Shiny Server is actually running:
# Check if Shiny Server is running
sudo systemctl status shiny-server
# If not running, start it
sudo systemctl start shiny-server
# Test locally
curl http://localhost:3838
The 504 Gateway Timeout error was occurring because nginx was trying to connect to your domain name instead of the local Shiny Server process. By changing it to 127.0.0.1:3838
, nginx will properly proxy requests to the locally running Shiny Server.
Oh and restart your Nginx server as well after the changes
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.