티스토리 뷰

Server/WebServer

serve single file on NGINX

Jacob_baek 2021. 3. 23. 22:30

아래 주소와 같이 바로 다운로드 및 실행이 가능한 환경을 만들고자 하는 need가 생겨 nginx web server로 구현하는 방법을 알아보았다.

nginx에서는 다음과 같은 setting을 추가하면 된다.
(여기서는 8088의 임의의 port로 listen한 대상이 파일의 content를 포함하여 출력되도록 하였다.)

    server {
      listen 8088;

      location "/" {
          add_header Content-Type text/plain;
          try_files /k3s.sh =404;
      }

결국 browser상에서 해당 파일을 뭐로 인지할것인지에 대한 부분으로 header에 content-type을 text/plain으로 표기하여
browser에서는 이를 text로 인지하게 되어 이를 출력하게 되고 만약 shell 로 이를 실행하고자 한다면 아래와 같은 명령을 추가하면
실행까지 가능하다.

curl -sfL http://localhost:8088 | sh -

참고사이트

'Server > WebServer' 카테고리의 다른 글

response custom error page from proxy server  (0) 2022.03.03
How to use nginx lua module  (0) 2022.02.21
print local ip address and hostname using php on httpd  (0) 2017.04.17
Apache Traffic Server (ATS)  (0) 2014.04.29
apache httpd module  (0) 2012.04.03
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함