miniserver:xenial
차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| miniserver:xenial [2016/06/04 14:22] – [Python 계열 세팅] changwoo | miniserver:xenial [2018/01/02 02:34] (현재) – [Torrent] 잘못된 스크립트 수정 changwoo | ||
|---|---|---|---|
| 줄 91: | 줄 91: | ||
| post_max_size = 64M | post_max_size = 64M | ||
| </ | </ | ||
| + | |||
| + | ==== pool 조정 ==== | ||
| + | 특정 사이트의 PHP 실행 유저를 다르게 만들어 동작시킬 때 사용한다. | ||
| + | ''/ | ||
| + | |||
| + | nginx설정에서 원하는 사이트의 fastcgi 소켓 경로를 변경해 준다. | ||
| + | opcache 문제도 있을 수 있는데, 이건 그냥 스킵. | ||
| + | |||
| + | [[https:// | ||
| ===== NGINX ===== | ===== NGINX ===== | ||
| 줄 112: | 줄 121: | ||
| location /phpmyadmin { | location /phpmyadmin { | ||
| alias / | alias / | ||
| + | index index.php index.html index.htm; | ||
| + | location ~ ^/ | ||
| + | root /usr/share; | ||
| + | fastcgi_pass unix:/ | ||
| + | fastcgi_index index.php; | ||
| + | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
| + | include fastcgi_params; | ||
| + | } | ||
| } | } | ||
| - | location ~ ^/ | ||
| - | root /usr/share; | ||
| - | fastcgi_pass unix:/ | ||
| - | include snippets/ | ||
| - | } | ||
| </ | </ | ||
| 줄 128: | 줄 140: | ||
| ==== Dokuwiki ==== | ==== Dokuwiki ==== | ||
| + | |||
| <code - vhost-wiki.conf> | <code - vhost-wiki.conf> | ||
| # Nginx Configuration | # Nginx Configuration | ||
| + | |||
| + | # 아래 설정은 https 적용 이후 http -> https 이동에 사용됨. | ||
| + | server { | ||
| + | listen 80; | ||
| + | server_name | ||
| + | return | ||
| + | } | ||
| server { | server { | ||
| 줄 182: | 줄 202: | ||
| </ | </ | ||
| + | nginx라면 복구 이후 멋진 URL에서 .htaccess 방식을 선택해야 문서가 올바르게 보인다. | ||
| ==== WordPress ==== | ==== WordPress ==== | ||
| 이 녀석은 조금 복잡하다. | 이 녀석은 조금 복잡하다. | ||
| 줄 258: | 줄 279: | ||
| <code - vhost-wordpress.conf> | <code - vhost-wordpress.conf> | ||
| + | |||
| + | # 아래 설정은 https 적용 이후 http -> https 이동에 사용됨. | ||
| + | server { | ||
| + | listen 80; | ||
| + | server_name | ||
| + | return | ||
| + | } | ||
| + | |||
| server { | server { | ||
| server_name blog.changwoo.pe.kr; | server_name blog.changwoo.pe.kr; | ||
| 줄 265: | 줄 294: | ||
| index index.php; | index index.php; | ||
| - | include | + | # wp-login.php, |
| + | location ~ ^/(wp-admin(?!/admin-ajax\.php)|wp-login.php) { | ||
| + | allow 192.168.0.0/24; | ||
| + | deny all; | ||
| + | include snippets/ | ||
| + | fastcgi_pass unix:/ | ||
| + | } | ||
| + | include / | ||
| include / | include / | ||
| } | } | ||
| 줄 273: | 줄 309: | ||
| ==== Ampache ==== | ==== Ampache ==== | ||
| + | 그동안 모바일 기기에서 제대로 재생이 되지 않는 문제가 있었다가, | ||
| + | |||
| + | <code nginx vhost-ampache.conf> | ||
| + | server { | ||
| + | |||
| + | # listen to | ||
| + | # | ||
| + | listen | ||
| + | |||
| + | server_name stream.changwoo.pe.kr; | ||
| + | charset utf-8; | ||
| + | |||
| + | # Logging, error_log mode [notice] is necessary for rewrite_log on, | ||
| + | # (very usefull if rewrite rules do not work as expected) | ||
| + | |||
| + | | ||
| + | | ||
| + | # rewrite_log | ||
| + | |||
| + | # only optional for ssl encryption enabled: Path to certificate/ | ||
| + | |||
| + | # ssl_certificate | ||
| + | # ssl_certificate_key | ||
| + | |||
| + | root / | ||
| + | index index.php; | ||
| + | |||
| + | # Somebody said this helps, in my setup it doesn' | ||
| + | proxy_max_temp_file_size 0; | ||
| + | |||
| + | # Rewrite rule for Subsonic backend | ||
| + | if ( !-d $request_filename ) { | ||
| + | rewrite ^/ | ||
| + | rewrite ^/ | ||
| + | } | ||
| + | |||
| + | # Rewrite rule for Channels | ||
| + | if (!-d $request_filename){ | ||
| + | rewrite ^/ | ||
| + | } | ||
| + | |||
| + | # Beautiful URL Rewriting | ||
| + | # rewrite ^/ | ||
| + | # rewrite ^/ | ||
| + | # rewrite ^/ | ||
| + | # rewrite ^/ | ||
| + | |||
| + | # Subsonic Apps (not working!) | ||
| + | # rewrite ^/ | ||
| + | # rewrite ^/ | ||
| + | # rewrite ^/ | ||
| + | |||
| + | # the following line was needed for me to get downloads of single songs to work | ||
| + | rewrite ^/ | ||
| + | | ||
| + | location /play/ssid { | ||
| + | if (!-e $request_filename) { | ||
| + | # Subsonic Apps | ||
| + | rewrite ^/ | ||
| + | rewrite ^/ | ||
| + | rewrite ^/ | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | location /play { | ||
| + | if (!-e $request_filename) { | ||
| + | rewrite ^/ | ||
| + | break; | ||
| + | } | ||
| + | |||
| + | rewrite ^/ | ||
| + | rewrite ^/ | ||
| + | break; | ||
| + | } | ||
| + | |||
| + | | ||
| + | limit_except GET POST { | ||
| + | deny all; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | | ||
| + | deny all; | ||
| + | return 403; | ||
| + | } | ||
| + | |||
| + | | ||
| + | deny all; | ||
| + | return 403; | ||
| + | } | ||
| + | |||
| + | | ||
| + | limit_except GET POST HEAD{ | ||
| + | deny all; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | | ||
| + | try_files $uri = 404; | ||
| + | fastcgi_index index.php; | ||
| + | |||
| + | # sets the timeout for requests in [s] , 60s are normally enough | ||
| + | fastcgi_read_timeout 600s; | ||
| + | |||
| + | include fastcgi_params; | ||
| + | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
| + | |||
| + | # Mitigate HTTPOXY https:// | ||
| + | fastcgi_param HTTP_PROXY ""; | ||
| + | |||
| + | # has to be set to on if encryption (https) is used: | ||
| + | # fastcgi_param HTTPS on; | ||
| + | |||
| + | fastcgi_split_path_info ^(.+? | ||
| + | |||
| + | # chose as your php-fpm is configured to listen on | ||
| + | fastcgi_pass unix:/ | ||
| + | # fastcgi_pass 127.0.0.1: | ||
| + | } | ||
| + | |||
| + | # Rewrite rule for WebSocket | ||
| + | | ||
| + | rewrite ^/ws/(.*) /$1 break; | ||
| + | proxy_http_version 1.1; | ||
| + | proxy_set_header Upgrade $http_upgrade; | ||
| + | proxy_set_header Connection " | ||
| + | proxy_set_header Host $host; | ||
| + | proxy_pass http:// | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| ==== Python 계열 세팅 ==== | ==== Python 계열 세팅 ==== | ||
| 내가 운용 중인 모든 애플리케이션은 Python3로 작성되어 있으니, 그 쪽으로 세팅을 맞춘다. | 내가 운용 중인 모든 애플리케이션은 Python3로 작성되어 있으니, 그 쪽으로 세팅을 맞춘다. | ||
| 줄 319: | 줄 488: | ||
| === uWSGI === | === uWSGI === | ||
| + | |||
| + | 앱이 하나일 때는 아래와 같이 간단하게 master로 돌렸다. | ||
| <code - miniserver-apps.ini> | <code - miniserver-apps.ini> | ||
| [uwsgi] | [uwsgi] | ||
| 줄 343: | 줄 514: | ||
| daemonize = < | daemonize = < | ||
| </ | </ | ||
| + | |||
| + | 그러나 복수의 앱을 운영해야 할 시점이 생기자 엡퍼러(emperor) 모드가 필요해졌다. 엠퍼러 모드는 간단하게 이렇게 쓸 수 있다. | ||
| + | |||
| + | <code - uwsgi-emperor.ini> | ||
| + | uid=owner | ||
| + | |||
| + | daemonize=< | ||
| + | |||
| + | emperor=< | ||
| + | |||
| + | </ | ||
| + | |||
| + | < | ||
| === rc.local === | === rc.local === | ||
| 줄 357: | 줄 541: | ||
| uwsgi --reload / | uwsgi --reload / | ||
| kill -HUP `cat / | kill -HUP `cat / | ||
| + | killall -s INT uwsgi | ||
| </ | </ | ||
| 줄 379: | 줄 564: | ||
| create mask = 0644 | create mask = 0644 | ||
| directory mask = 0755 | directory mask = 0755 | ||
| + | </ | ||
| + | |||
| + | 심볼릭 링크를 추가하기 위해 다음과 같은 세팅을 주었다((http:// | ||
| + | < | ||
| + | [global] | ||
| + | allow insecure wide links = yes | ||
| + | |||
| + | [share] | ||
| + | follow symlinks = yes | ||
| + | wide links = yes | ||
| </ | </ | ||
| 줄 497: | 줄 692: | ||
| <code - deluge-daemon> | <code - deluge-daemon> | ||
| #!/bin/sh | #!/bin/sh | ||
| - | ### BEGIN INIT INFO | ||
| - | # Provides: | ||
| - | # Required-Start: | ||
| - | # Required-Stop: | ||
| - | # Should-Start: | ||
| - | # Should-Stop: | ||
| - | # Default-Start: | ||
| - | # Default-Stop: | ||
| - | # Short-Description: | ||
| - | # Description: | ||
| - | # / | ||
| - | ### END INIT INFO | ||
| - | |||
| - | # Author: Adolfo R. Brandes | ||
| - | # Updated by: Jean-Philippe " | ||
| - | |||
| - | PATH=/ | ||
| - | DESC=" | ||
| - | NAME1=" | ||
| - | NAME2=" | ||
| - | DAEMON1=/ | ||
| - | DAEMON1_ARGS=" | ||
| - | DAEMON2=/ | ||
| - | DAEMON2_ARGS="" | ||
| - | PIDFILE1=/ | ||
| - | PIDFILE2=/ | ||
| - | UMASK=022 | ||
| - | PKGNAME=deluge-daemon | ||
| - | SCRIPTNAME=/ | ||
| - | |||
| - | # Exit if the package is not installed | ||
| - | [ -x " | ||
| - | |||
| - | # Read configuration variable file if it is present | ||
| - | [ -r / | ||
| - | |||
| - | # Load the VERBOSE setting and other rcS variables | ||
| - | [ -f / | ||
| - | |||
| - | # Define LSB log_* functions. | ||
| - | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. | ||
| - | . / | ||
| - | |||
| - | if [ -z " | ||
| - | then | ||
| - | | ||
| - | exit 0 | ||
| - | fi | ||
| - | |||
| - | if [ -z " | ||
| - | then | ||
| - | log_warning_msg "Not starting $PKGNAME, DELUGED_USER not set in / | ||
| - | exit 0 | ||
| - | fi | ||
| - | |||
| - | # | ||
| - | # Function to verify if a pid is alive | ||
| - | # | ||
| - | is_alive() | ||
| - | { | ||
| - | | ||
| - | kill -0 $pid > /dev/null 2>&1 | ||
| - | | ||
| - | } | ||
| - | |||
| - | # | ||
| - | # Function that starts the daemon/ | ||
| - | # | ||
| - | do_start() | ||
| - | { | ||
| - | # Return | ||
| - | # | ||
| - | # | ||
| - | # | ||
| - | |||
| - | | ||
| - | | ||
| - | |||
| - | if [ $RETVAL1 != 0 ]; then | ||
| - | rm -f $PIDFILE1 | ||
| - | | ||
| - | | ||
| - | | ||
| - | else | ||
| - | | ||
| - | | ||
| - | [ " | ||
| - | fi | ||
| - | |||
| - | | ||
| - | | ||
| - | |||
| - | if [ $RETVAL2 != 0 ]; then | ||
| - | sleep 2 | ||
| - | rm -f $PIDFILE2 | ||
| - | start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile \ | ||
| - | --exec $DAEMON2 --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON2_ARGS | ||
| - | RETVAL2=" | ||
| - | fi | ||
| - | [ " | ||
| - | } | ||
| - | |||
| - | # | ||
| - | # Function that stops the daemon/ | ||
| - | # | ||
| - | do_stop() | ||
| - | { | ||
| - | # Return | ||
| - | # | ||
| - | # | ||
| - | # | ||
| - | # | ||
| - | |||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | [ " | ||
| - | |||
| - | rm -f $PIDFILE1 $PIDFILE2 | ||
| - | |||
| - | [ " | ||
| - | } | ||
| - | |||
| - | case " | ||
| - | start) | ||
| - | [ " | ||
| - | | ||
| - | case " | ||
| - | 0|1) [ " | ||
| - | 2) [ " | ||
| - | esac | ||
| - | ;; | ||
| - | stop) | ||
| - | [ " | ||
| - | | ||
| - | case " | ||
| - | 0|1) [ " | ||
| - | 2) [ " | ||
| - | esac | ||
| - | ;; | ||
| - | restart|force-reload) | ||
| - | | ||
| - | | ||
| - | case " | ||
| - | 0|1) | ||
| - | do_start | ||
| - | case " | ||
| - | 0) log_end_msg 0 ;; | ||
| - | 1) log_end_msg 1 ;; # Old process is still running | ||
| - | *) log_end_msg 1 ;; # Failed to start | ||
| - | esac | ||
| - | ;; | ||
| - | *) | ||
| - | # Failed to stop | ||
| - | log_end_msg 1#!/bin/sh | ||
| ### BEGIN INIT INFO | ### BEGIN INIT INFO | ||
| # Provides: | # Provides: | ||
| 줄 809: | 줄 848: | ||
| # Failed to stop | # Failed to stop | ||
| log_end_msg 1 | log_end_msg 1 | ||
| - | ;; | ||
| - | esac | ||
| - | ;; | ||
| - | *) | ||
| - | echo " | ||
| - | exit 3 | ||
| - | ;; | ||
| - | esac | ||
| - | |||
| - | : | ||
| ;; | ;; | ||
| esac | esac | ||
| 줄 872: | 줄 901: | ||
| </ | </ | ||
| + | |||
| + | ===== Resilio-Sync ===== | ||
| + | [[https:// | ||
| + | |||
| + | 가정용은 무료이니 나같이 그냥 비디오 디렉토리 공유하는 수준에서는 괜찮은 선택인 것 같다. | ||
| + | |||
| + | deb 패키지가 제공되니 깔아 주면 그만이다. service resilio-sync start 명령으로 실행하면 되는데, 변경은 다음과 같은 명령으로 | ||
| + | <code bash> | ||
| + | $ sudo systemctl edit resilio-sync.service | ||
| + | |||
| + | [Service] | ||
| + | User=changwoo | ||
| + | Group=changwoo | ||
| + | PIDFile= | ||
| + | PIDFile=/ | ||
| + | ExecStartPre= | ||
| + | ExecStartPre=/ | ||
| + | ExecStartPre=/ | ||
| + | ExecStart= | ||
| + | ExecStart=/ | ||
| + | </ | ||
| + | |||
| + | systemctl edit 명령은 파일 자체를 변경하는 것이 아니라 overriding 하는 방식이다.그리고 override 할 때 기존 명령어는 한번 비워주는 작업이 필요하다. 그래서 "'' | ||
| + | |||
| + | <code bash> | ||
| + | $ sudo systemctl cat resilio-sync.service | ||
| + | |||
| + | [Unit] | ||
| + | Description=Resilio Sync service | ||
| + | Documentation=https:// | ||
| + | After=network.target network-online.target | ||
| + | |||
| + | [Service] | ||
| + | Type=forking | ||
| + | User=rslsync | ||
| + | Group=rslsync | ||
| + | UMask=0002 | ||
| + | Restart=on-failure | ||
| + | PermissionsStartOnly=true | ||
| + | PIDFile=/ | ||
| + | ExecStartPre=/ | ||
| + | ExecStartPre=/ | ||
| + | ExecStart=/ | ||
| + | |||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| + | |||
| + | # / | ||
| + | [Service] | ||
| + | User=changwoo | ||
| + | Group=changwoo | ||
| + | PIDFile= | ||
| + | PIDFile=/ | ||
| + | ExecStartPre= | ||
| + | ExecStartPre=/ | ||
| + | ExecStartPre=/ | ||
| + | ExecStart= | ||
| + | ExecStart=/ | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | 이렇게 덧붙여지는 것을 참고하자. | ||
| + | ===== SSL 설비 ===== | ||
| + | 이제는 필수로 구비하자. Let's Encrypt가 있다. 아래의 가이드를 따라하면 어렵지 않다. | ||
| + | * https:// | ||
| + | * http:// | ||
| + | 3개월마다 갱신해야 하는데, 나는 아직 자동 갱신을 하지는 않았다. 나중에 확인하고 달아 보도록 하자. | ||
miniserver/xenial.1465050146.txt.gz · 마지막으로 수정됨: 2016/06/04 14:22 저자 changwoo
