http://fehead.tistory.com/216 참고


1. 여기서  http://freedns.afraid.org/ FREE 동적 DNS를 먼저 구한다.


동적DNS를 무료로 사용해보자 - FreeDNS - 여기를 참고 하라.



2. freedns 에서 키값을 얻는다.

http://freedns.afraid.org/dynamic/ 에 들어가서 중앙 하단 부분에 자기가 등록한 도메인이 있을 것이고 그 아래쪽에 Direct URL 를 클릭하면 새창이 뜬다.



 






여기서 나온 URL부분에

빨간 상자 부분이 키 값이다.


3. Padavan 설정





고급설정 -> WAN ->DDNS 메뉴로 간다음

DDNS 클라이언트 활성화

서버 프로필을 "freedns.afraid.org" 선택

호스트에 "freedns.afraid.org"

토큰에 freedns.afraid.org  에서 얻은 키값을 넣는다.

보안 HTTPS 연결을 사용 하시겠습니까? "아니오" 선택

적용 버튼을 누른다.



라즈베리파이2에 usb 무선동굴이를 설치하고 무선공유기에 접속해서 쓰고 있다.


동굴이는 EFM ipTIME N100mini usb 2.0 를 사다가 끼웠다.


무선공유기 ssid가 myssid 이고 비밀번호가 mypassword이면 아래와 같이 하고 재부팅 하면 된다.


$ sudo -i

# rpi-update

# wpa_passphrase myssid mypassword >>  /etc/wpa_supplicant/wpa_supplicant.conf

# vi /etc/wpa_supplicant/wpa_supplicant.conf


/etc/wpa_supplicant/wpa_supplicant.conf 수정.

# /etc/wpa_supplicant/wpa_supplicant.conf

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1         # 추가
ap_scan=1               # 추가.

network={
        ssid="myssid"
        scan_ssid=1              # 마지막에 추가된 myssid란에 추가.
        #psk="mypassword"
        psk=2f0568b3492812bd56b946dbaf3fd7dd669b9a4602a09aa6462ff057949b025c
}
 


재부팅

# reboot


postfix 메일서버 설치 방법


$ sudo -i

# apt install postfix

# vi /etc/postfix/main.cf

mynetworks = 127.0.0.0/8 192.168.0.0/24  # 192.168.0.0/24 - 메일을 보낼수 있는 ip 대역 추가.

# systemctl enable postfix.service

# systemctl start postfix.service

# mail -s "email title" user@test.com

mail test...

ctrl + d


#

 



tomcat 서버설정
Server.xml을 설정합니다.


[설정방법]
< Connector port="포트번호" protocol="HTTP/1.1" SSLEnabled="true"
               maxThread="150" scheme="https" secure="true"
               keystoreFile="pfx파일경로" keystorePass="pfx패스워드" keystoreType="PKCS12"
               clientAuth="false" sslProtocol="TLS" />


[설정예제]  
< Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThread="150" scheme="https" secure="true"
               keystoreFile="/etc/tomcat/ssl/example.com.pfx" keystorePass="123456" keystoreType="PKCS12"
               clientAuth="false" sslProtocol="TLS" />



URL : https://www.comodossl.co.kr/certificate/ssl-installation-guides/Tomcat-pfx.aspx

가상환경 설정

$ cd /my/working/dir

$ virtualenv -p python3 env35

$ cd env35

$ mkdir run

$ source bin/activate

$ pip install django gunicorn

$ django-admin startproject testproject

$ cd testproject

$ django-admin startapp testapp


디렉토리 구조

/my/working/dir


`-- env35
    |-- bin
    |  
    |-- include
    |   `-- python3.5m -> /usr/include/python3.5m
    |-- lib
    |   `-- python3.5
    |-- testproject
    |   |-- media
    |   |-- testproject
    |   |-- static
    |   |-- templates
    |   `-- testapp
    `-- run



gunicorn systemd 등록

$ sudo mkdir /run/gunicorn

$ sudo chown youurUserName.yourGroup /run/gunicorn

# sudo vi /etc/systemd/system/gunicorn.service

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
PIDFile=/run/gunicorn/pid
User=youurUserName
Group=yourGroup
WorkingDirectory=/my/working/dir/env35/testproject
ExecStart=/my/working/dir/env35/bin/gunicorn \
        --pid /run/gunicorn/pid \
        --workers 2 \
        --bind unix:/run/gunicorn/gunicorn.sock \
        testproject.wsgi:application

ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target


gunicorn 서비스 시작

$ sudo systemctrl enable gunicorn.service

$ sudo systemctl start gunicorn.service



# 가상환경 설정

$ virtualenv -p python3 env35

$ cd envDjango

$ mkdir run

$ source bin/activate

$ pip install django gunicorn

$ django-admin startproject testproject

$ cd testproject

$ django 작업

$ cat << EOF > gunicorn_cfg.py
daemon=True
bind='unix:/your/dir/env35/run/gunicorn.sock'
workers=3
EOF

$ gunicorn -c gunicorn_cfg.py testproject.wsgi:application

$ sudo -i

# apt install nginx

# cd /etc/nginx/sites-available/

# cat << EOF > testproject_conf
server {
        listen 80;
        server_name    ${YOUR_SERVER_NAME};
        root        /usr/share/nginx/html;

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

        location /static {
                root    root ${YOUR_PROJECT_DIR};
        }

        location / {
                include proxy_params;
                proxy_pass http://unix:/your/dir/env35/run/gunicorn.sock;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
}
EOF

# cd ../sites-enabled/

# ln -s ../sites-available/testproject_conf

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

# nginx -s reload



아래에 링크에 자세한 설명

http://dveamer.github.io/backend/PythonWAS.html

/etc/ssh/sshd_config 파일를 수정하고 재시작

# /etc/ssh/sshd_config

UseDNS no  # 추가


# 위의것으도 안되면

GSSAPIAuthentication no  # 이것추가.
GSSAPICleanupCredentials yes # 이것추가.


위의 방법이 안된다면..

systemd-logind.service 서비스를 재시작한다.

# systemctl restart systemd-logind.service


그런데 이게 재시작이 안될경우가 있다

이럴때는 systemctl 데몬을 재시작한다.

# systemctl daemon-reexec 



참고 URL : https://unix.stackexchange.com/questions/393394/systemd-logind-service-fails-to-start-when-attempting-to-return-from-rescue-tar

Error Message :

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

...

..

Cause: java.lang.NullPointerException



solution

Fucking MsSql Table Chahge Column Attribute "NVARCHAR" to "VARCHAR"


이것때문에 2주를 고생했다..

sql은 분명히 맞는데 결과값이 null이거나 아무것도 안나온다


위 메세지가 나온다면 

Sql server 테이블 컬럼 속성중에  NVARCHAR 를 VARCHAR로 바꿔라..


nginx 설정


vi /etc/nginx/sites-available/default  에 최상단에 아래 내용 추가.

upstream        tomcat {
         server  127.0.0.1:8080  fail_timeout=0;
 }


nginx 첫번재 도메인(www.hoticel.net) 설정

# 예제 1. http://www.hoticel.net

vi /etc/nginx/sites-available/www.hoticle.net

# hoticle.net => www.hoticle.net
server {
        listen 80;
        server_name hoticle.net;
        return 301 $scheme://www.hoticle.net$request_uri;
}

# www.hoticle.net 설정
server {
        listen 80;
        listen [::]:80;

        server_name www.hoticle.net;

        # Let's Encrypt 관련 디렉토리
        location /.well-known {
                # Note that a request for /.well-known/test.html whill
                # look for /var/www/ssl-prof-rancher/.well-known/test.html
                # and not /var/www/ssl-proof/rancher/test.html
                root /var/www/ssl-proof/tomcat/;
        }

        location / {
                proxy_redirect off;
                proxy_pass_header Server;

                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Port $server_port;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Scheme $scheme;
                proxy_pass http://tomcat;
                charset utf-8;
        }
}
 



두번째 도메인 설정 ( www.bbb.net )

# 예제 1. http://www.bbb.net

vi /etc/nginx/sites-available/www.bbb.net

# www.bbb.net 설정
server {
        listen 80;
        listen [::]:80;

        server_name www.bbb.net;

        # Let's Encrypt 관련 디렉토리
        location /.well-known {
                # Note that a request for /.well-known/test.html whill
                # look for /var/www/ssl-prof-rancher/.well-known/test.html
                # and not /var/www/ssl-proof/rancher/test.html
                root /var/www/ssl-proof/tomcat/;
        }

        location / {
                proxy_redirect off;
                proxy_pass_header Server;

                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Port $server_port;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Scheme $scheme;
                proxy_pass http://tomcat;
                charset utf-8;
        }




# nginx 문법 테스트

nginx -t

# nginx 재시작

systemctl restart nginx.service



Tomcat 설정


server.xml 설정

vi /etc/tomcat/server.xml

 <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               address="127.0.0.1"
               redirectPort="8443" />

...


       <Host name="www.hoticle.net" appBase="/var/www/Hoticle" autoDeploy="true"  xmlValidation="false" xmlNamespaceAware="false">
              <Context path="/" docBase="" reloadable="true" />
      </Host>
      <Host name="www.bbb.net" appBase="/var/www/bbb" autoDeploy="true"  xmlValidation="false" xmlNamespaceAware="false">
              <Context path="/" docBase="" reloadable="true" />
      </Host>


  </Engine>

  </Service>
</Server> 



# tomcat 재실행

systemctl restart tomcat8.service



Let's Encrypt

Let's Encrypt  실행

# certbot --nginx -d www.hoticel.net -d www.bbb.net



crontab 등록

# Let's Encrypt
30 2 * * * certbot renew --noninteractive --renew-hook "/bin/systemctl reload nginx" >> /var/log/le-renew.log



참고 사이트 :

https://tom.busby.ninja/letsecnrypt-nginx-reverse-proxy-no-downtime/
https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-debian-8

# cat /etc/nginx/sites-available/default
# Default server configuration
#
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ ^/~(?<user>.+?)(?<path>/.*)?$ {
                alias /home/$user/public_html$path;
                autoindex on;

                location ~ \.php$ {
                        if (!-f $request_filename) { return 404; }

                        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                        fastcgi_intercept_errors on;
                        include fastcgi_params;
                        fastcgi_param  SCRIPT_FILENAME $request_filename;
                }
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;

                # With php7.0-cgi alone:
                # fastcgi_pass 127.0.0.1:9000;
                # With php7.0-fpm:
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }



        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
                deny all;
        }


+ Recent posts