Remark42 without a subdomain (remark.css - 404) #967
Replies: 8 comments 4 replies
-
this information is not sufficient to answer anything reasonable. As this is not a bug report moved to discussions |
Beta Was this translation helpful? Give feedback.
-
The subdomain configuration works fine. Using Remark42 without a subdomain has several advantages. When trying to apply "How to configure remark42 without a subdomain", the remark.css request from iframe.html returns a 404 error. |
Beta Was this translation helpful? Give feedback.
-
user nginx;
pid /var/run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 8192;
error_log /var/log/nginx/error.log warn;
events {worker_connections 4096;}
http {
sendfile on;
tcp_nopush on;
include /etc/nginx/mime.types;
charset UTF-8;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_session_tickets on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
ssl_stapling on;
ssl_stapling_verify on;
ssl_buffer_size 4k;
ssl_early_data on;
resolver 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4;
resolver_timeout 2s;
access_log off;
log_not_found off;
gzip_vary on;
gzip_proxied any;
server {
listen 80;
listen [::]:80;
server_name domain.com www.domain.com;
return 301 https://domain.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/nginx/ssl/domain.com.cert.pem;
ssl_certificate_key /etc/nginx/ssl/domain.com.key.pem;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
server_name www.domain.com;
return 301 https://domain.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/nginx/ssl/domain.com.cert.pem;
ssl_certificate_key /etc/nginx/ssl/domain.com.key.pem;
root /var/www/domain.com/html;
server_name domain.com;
access_log /var/log/nginx/domain.com.log;
error_page 404 /404.htm;
location =/404.htm {etag off;}
gzip_static on;
rewrite (.*).gz$ $1 permanent;
index index.htm;
if ($request_uri ~ ^(.*/)index.htm$) {return 301 $1;}
location ~.(png|jpg|ico|cur|css)$ {add_header Cache-Control "public, max-age=31536000, immutable";}
location ~.exe$ {add_header Cache-Control no-cache;}
location ~.htm$ {
add_header Cache-Control no-cache;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
}
location =/version.txt {add_header Cache-Control no-cache;}
location =/robots.txt {add_header Cache-Control "public, max-age=604800"; add_header X-Robots-Tag noindex;}
location =/sitemap.xml {add_header Cache-Control no-cache; add_header X-Robots-Tag noindex;}
location /remark42/ {
rewrite /remark42/(.*) /$1 break;
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $http_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;
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Command line. Start as a systemd service.
<div id="remark42"></div>
<script>
var remark_config = {host: "https://domain.com/remark42", site_id: 'domain.com', url: 'https://domain.com/index.htm'};
!function(e,n){for(var o=0;o<e.length;o++){var r=n.createElement("script"),c=".js",d=n.head||n.body;"noModule"in r?(r.type="module",c=".mjs"):r.async=!0,r.defer=!0,r.src=remark_config.host+"/web/"+e[o]+c,d.appendChild(r)}}
(remark_config.components||["embed"],document);
</script>
|
Beta Was this translation helpful? Give feedback.
-
Embedding into a real page. |
Beta Was this translation helpful? Give feedback.
-
well, obviously you not even reaching remark42 assets. My guess will be - some other part of your nginx configuration prevented it. Not sure what part, but would suggest making the simplest config, like in docs, and make sure it works. Adding your other part after this piece by piece till it stops may help to figure what the issue is. |
Beta Was this translation helpful? Give feedback.
-
Using the exclusion method, I found a line in the nginx configuration that causes this effect: location ~.(png|jpg|ico|cur|css)$ {add_header Cache-Control "public, max-age=31536000, immutable";} But I don't understand why this is happening. |
Beta Was this translation helpful? Give feedback.
-
I completely forgot that regular expressions are searched after prefix comparisons. The most optimal solution would be to use the location ^~ /remark42/ {
rewrite /remark42/(.*) /$1 break;
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $http_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;
} |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions