Trying to do something with uploadable.name works on localhost, but not under reverse proxy #607
-
For file uploads, I am trying to get the original filename of the image/video and set it as <span class='filename'><%= ctx.uploadable.name %></span> So, supposedly if (uploadable.url) {
post.source = uploadable.url;
} else {
post.source = uploadable.name;
} This works fine as expected when I am using the site through localhost, at ip 127.0.0.1 (directly or through ssh -L), but fails when I deploy the site behind a reverse proxy and try to access it through https://example.com. Fails as in the source gets null value. I don't understand what's happening. I guess it's a faulty js code that my browser doesn't care when executing on localhost, but stops it from happening when it's on a public site with tls? If anyone can shed some light, I will be grateful. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This is my full nginx config file, only redacted my deploy domain name, except that everything is here. Did I forget to x-forward something? limit_req_zone $binary_remote_addr zone=throttle:10m rate=25r/s;
server {
server_name example.com www.example.com;
access_log /var/log/nginx/reverse-access-example.com.log;
error_log /var/log/nginx/reverse-error-example.com.log;
location = /robots.txt {
return 200 "User-agent: *\nDisallow: /\n";
}
client_max_body_size 10000M;
client_body_timeout 30s;
server_tokens off;
location / {
# auth_basic "Restricted Content";
# auth_basic_user_file /etc/nginx/.htpasswd;
limit_req zone=throttle burst=5 delay=3;
proxy_pass http://127.0.0.1:8080/;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_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-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_read_timeout 1d;
proxy_set_header X-Script-Name /szuru;
error_page 500 501 502 504 505 506 507 508 509 510 511 @err;
error_page 503 @throttle;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
add_header X-XSS-Protection "1; mode=block";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
add_header Referrer-Policy "strict-origin";
}
location @err {
return 500 "server error. please try again later.";
default_type text/plain;
}
location @throttle {
return 503 "we've detected abuse on your ip. please wait and try again later.";
default_type text/plain;
}
listen [::]:443 ssl http2;
listen 443 ssl http2;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
ssl_stapling on;
ssl_stapling_verify on;
}
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
}
if ($host = example.com) {
return 301 https://$host$request_uri;
}
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 404;
} |
Beta Was this translation helpful? Give feedback.
-
Uh it was a cloudflare caching problem. Turning off the caching in CF dashboard and/or using something like app.min.js?v=2 in index html fixes this. |
Beta Was this translation helpful? Give feedback.
Uh it was a cloudflare caching problem. Turning off the caching in CF dashboard and/or using something like app.min.js?v=2 in index html fixes this.