Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx configuration #3984

Open
Daishoulu opened this issue Feb 27, 2024 · 0 comments
Open

Nginx configuration #3984

Daishoulu opened this issue Feb 27, 2024 · 0 comments

Comments

@Daishoulu
Copy link

Daishoulu commented Feb 27, 2024

Hello, I encountered an issue while configuring Nginx for Shiny. I referred to the instructions provided in the "Running Shiny Server with a Proxy" article at https://support.posit.co/hc/en-us/articles/213733868 to configure Nginx for Shiny, but I ran into a problem with my Nginx configuration.

user sldai;
worker_processes auto;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Security headers
server_tokens off;
#add_header Content-Security-Policy "default-src 'self';";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_comp_level 2;
gzip_vary on;

map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}
# HTTP server block
server {
    listen 80;
    server_name my.xxxxx.com;

    # Redirect all HTTP traffic to HTTPS
    return 301 https://$server_name$request_uri;
}

# HTTPS server block
server {
    listen 443 ssl;
    server_name my.xxxxx.com;
    ssl_certificate /etc/nginx/cert/FullSSL.crt;
    ssl_certificate_key /etc/nginx/cert/SSL.key;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 5m;
    ssl_stapling off;
    charset utf-8;
    client_max_body_size 1G;

    access_log path/to/nginx/log/access.log main;
    error_log path/to/nginx/log/error.log warn;

    # Location block for Shiny Server
    location /shiny-server/ {
    		rewrite ^/shiny-server/(.*)$ /$1 break;
        proxy_pass http://127.0.0.1:3838;
        proxy_redirect http://127.0.0.1:3838/ $scheme://$host/shiny-server/;
        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;
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
					proxy_buffering off;
        proxy_read_timeout 20d;
    }
}

}

However, both the Nginx and Shiny logs do not show any error messages,the console displays the following error:

   GET https://my.xxxxx.com/shiny-server/test/__assets__/shiny-server.css/ net::ERR_ABORTED 404 (Not Found)	test/:21 

   GET https://my.xxxxx.com/shiny-server/test/__assets__/sockjs.min.js/ net::ERR_ABORTED 404 (Not Found)  test/:18 

   GET https://my.xxxxx.com/shiny-server/test/__assets__/shiny-server-client.min.js/ net::ERR_ABORTED 404 (Not Found)  test/:19 
截屏2024-02-27 20 46 49

I have spent a day without finding the cause of this problem and hope to get your help!
[root@localhost nginx]# shiny-server --version
Shiny Server v1.5.21.1012
[root@localhost nginx]# nginx -V
nginx version: nginx/1.24.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant