특정 애드온이나, 모듈 소스에서 파일을 ./addons/~~ 와 같은 경로로 로딩하도록 하였을 때

 

짧은 주소를 사용하지 않을 때에는 문제가 없는데

 

짧은 주소를 사용하게 되면

 

ex) free mid명을 지니는 게시판에서 글을 읽을 때

 

https://나의 사이트 주소/free/addons/~~

 

이와같이 mid명 뒤에 addons 폴더가 붙어버려서 파일을 불러오지 못 하는 경우가 종종 생깁니다.

 

XETOWN에 올려주신 ad_parser 애드온도 현재 짧은 주소 사용 시 오류가 발생하고 있구요..

 

혹시 이를 소스 수정 없이 nginx rewrite_rule 을 통해 해결할 수 있는 방법이 있을까요?

Atachment
첨부
  • profile

    XE 개발팀에서 제공하는 rewrite 규칙으로도 충분히 가능합니다.

    (static files라고 되어 있는 부분이 원하시는 기능입니다.)

     

    단, nginx는 설정 순서나 구조에 큰 영향을 받기 때문에

    location 안에 rewrite 규칙을 넣거나, location 안에 root가 있거나,

    gif, jpg, css, js 등의 파일을 처리하는 규칙이 먼저 나오거나 하면 제대로 작동하지 않을 수도 있습니다.

    설정파일의 다른 부분에 오류가 있어서 reload가 먹히지 않을 수도 있고요.

  • profile ?
    해당 부분이 https://github.com/rhymix/rhymix/blob/master/common/manual/server_config/rhymix-nginx.conf 부분에는 없는 것 같아서

    제일 하단에 static files 부분의 코드를 추가하였습니다

    일단 발생되던 문제는 사라졌는데, 혹시 잘 못 된 수정이지는 않겠지요?
  • ? profile

    아뇨, 라이믹스 버전에도 있습니다. 링크하신 파일의 21~24줄 부분입니다.
    rewrite보다 location + try_files로 구현하는 것이 더 효율적이기 때문에
    문법을 다르게 썼을 뿐 의미는 동일합니다.

    기존에 라이믹스 버전을 쓰셨는데도 제대로 작동하지 않았다면
    위에서 말씀드린 것처럼 location의 순서가 틀렸거나 다른 설정과 충돌하기 때문일 것입니다.

  • profile ?
    음... 어디가 문제일까요 ㅠㅠ

    location / {
    index index.php index.html;
    }

    # Allow Lets Encrypt Domain Validation Program
    location ^~ /.well-known/acme-challenge/ {
    allow all;
    }

    # Block dot file (.htaccess .htpasswd .svn .git .env and so on.)
    location ~ /\. {
    deny all;
    }

    # Block (log file, binary, certificate, shell script, sql dump file) access.
    location ~* \.(log|binary|pem|enc|crt|conf|cnf|sql|sh|key)$ {
    deny all;
    }

    # Block access
    location ~* (composer\.json|contributing\.md|license\.txt|readme\.rst|readme\.md|readme\.txt|copyright|artisan|gulpfile\.js|package\.json|phpunit\.xml)$ {
    deny all;
    }

    location = /favicon.ico {
    log_not_found off;
    access_log off;
    }

    location = /robots.txt {
    log_not_found off;
    access_log off;
    }

    # Block .php file inside upload folder. uploads(wp), files(drupal), data(gnuboard).
    location ~* /(?:uploads|default/files|data)/.*\.php$ {
    deny all;
    }

    # Add PHP handler
    location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
    return 404;
    }

    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;

    fastcgi_buffers 64 4k; # default 8 4k
    include fastcgi_params;
    }
    # Enable Cache Control
    location ~* \.(?:jpg|jpeg|png|gif|ico|gz|svg|svgz|ogg|mp4|webm|ogv|htc|cur|ttf|woff2|woff|eot)$ {
    expires 3M;
    access_log off;
    log_not_found off;
    valid_referers none blocked www.meeco.kr meeco.kr;
    if ($invalid_referer) { return 444; }
    add_header Cache-Control "public";
    }
    location ~* \.(?:css|js)$ {
    expires 1M;
    access_log off;
    log_not_found off;
    valid_referers none blocked www.meeco.kr meeco.kr;
    if ($invalid_referer) { return 444; }
    add_header Cache-Control "public";
    }

    include rhymix.conf;

    로 구성 후 rhymix.conf에 해당 링크의 내용을 집어넣어서 nginx 구동 중 입니다.
  • ? profile

    다른 모든 규칙들보다 먼저 인클루드해 보세요. location / 블럭 바로 밑에요.

    특히 이미지, CSS, JS 등을 처리하는 규칙은 반드시 XE rewrite 규칙보다 아래에 있어야 합니다.

    지금처럼 rewrite가 맨 아래에 있으면 다른 규칙에 먼저 걸려버립니다.

  • profile ?
    먼저 인클루드 하니까 정상작동하네요. 기존의 다른 설정과 중복되었나 봅니다.

    그런데 다른 설정들은 거진 보안 설정밖에 없는데,,,

    이렇게 되면 라이믹스 ReWRITE 규칙이 보안 설정보다 우선시 되는게 아닌가 해서 걱정이 조금 되긴 하네요 ㅠㅠ
  • ? profile
    아마 마지막 부분에 있는 이미지, CSS, JS 캐싱 설정이 문제였을 거예요.

    보안설정이라고 말씀하신 것들 중에는 점(.)으로 시작하는 파일 접근 금지처럼 라이믹스 rewrite 규칙과 중복되는 것도 있고, 워드프레스 및 그누보드 업로드 폴더 보호 기능처럼 XE/라이믹스에서는 전혀 필요하지 않은 것도 있으니 적당히 정리하시기 바랍니다.

    우선순위를 신경쓸 필요가 없도록, 처음부터 중복되지 않는 규칙을 만들어 쓰면 됩니다.