Skip to content
\n\n
grep -rlw no-referrer /var/www/html/webtop |\nwhile read FILE\ndo\n  sed -i 's/\\bno-referrer\\b/same-origin/g' \"$FILE\"\ndone\n
\n\n
    location / {\n      if ($http_referer ~ /webtop(?:/|\\?|$)) {\n        return 301 $scheme://$host/webtop$request_uri;\n      }\n      location ~ ^/webtop(?:/|$) {\n       # Usual configuration directives. If none, just leave this location block empty\n      }\n    }\n
\n\n
<IfModule mod_rewrite.c>\n  RewriteCond %{REQUEST_URI} !^/webtop(?:/|$)\n  RewriteCond %{HTTP_REFERER} /webtop(?:/|\\?|$)\n  RewriteRule ^ /webtop%{REQUEST_URI} [END,R=301]\n</IfModule>\n
\n

The above Nginx configuration says: If the request URI starts with /webtop do usual stuff or nothing special, to send response. If not, check its Referer. If the Referer starts with /webtop that means the request is for daedalOS and therefore redirect it to /webtop sub-directory. We only check the Referer if the URI does not start with /webtop, because those requests can be fulfilled normally without any rewriting or redirecting.

","upvoteCount":1,"url":"https://github.com/DustinBrett/daedalOS/discussions/449#discussioncomment-9850152"}}}
Discussion options

You must be logged in to vote

Here's the full working solution. It's server-side but it works. Suppose you want to serve daedalOS as example.com/webtop

After you run "yarn build" it will generate "out" directory.

  • Copy out directory: cp -a out /var/www/html/webtop
  • Run the following
find /var/www/html/webtop -type f -exec chmod 644 {} \;
find /var/www/html/webtop -type d -exec chmod 755 {} \;
  • Replace no-referrer by same-origin to make sure that XMLHttpRequests always send HTTP-Referer header
grep -rlw no-referrer /var/www/html/webtop |
while read FILE
do
  sed -i 's/\bno-referrer\b/same-origin/g' "$FILE"
done
  • Configure Nginx web server for domain.com. Put this in /etc/nginx/conf.d/domain.conf
    location / {
  …

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@murty2
Comment options

@DustinBrett
Comment options

@murty2
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by murty2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants