Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
public:computer:oracle_cloud [2021/02/27 02:05] – [Apache] alex | public:computer:oracle_cloud [2022/04/01 11:04] (current) – [Nginx] alex | ||
---|---|---|---|
Line 100: | Line 100: | ||
$ sudo iptables -P OUTPUT ACCEPT | $ sudo iptables -P OUTPUT ACCEPT | ||
$ sudo iptables -P FORWARD ACCEPT | $ sudo iptables -P FORWARD ACCEPT | ||
- | $ sudo iptables -F | + | $ sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT |
- | $ sudo iptables-save | + | $ sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT |
+ | $ sudo iptables -F # 재부팅 시 -F 옵션은 꺼진다. | ||
+ | # $ sudo iptables-save | ||
+ | $ sudo netfilter-persistent save # 이걸로 저장이 되는 것 같다. cf.) sudo netfilter-persistent reload | ||
$ sudo systemctl restart apache2 | $ sudo systemctl restart apache2 | ||
</ | </ | ||
Line 143: | Line 146: | ||
$ sudo systemctl restart apache2 | $ sudo systemctl restart apache2 | ||
</ | </ | ||
+ | |||
+ | ==== Nginx ==== | ||
+ | === Update apt === | ||
+ | <cli> | ||
+ | # sudo apt update && sudo apt upgrade -y | ||
+ | </ | ||
+ | |||
+ | === Install Nginx === | ||
+ | <cli> | ||
+ | # sudo apt install nginx | ||
+ | </ | ||
+ | |||
+ | === Execute Nginx === | ||
+ | <cli> | ||
+ | # sudo systemctl start nginx | ||
+ | # sudo systemctl status nginx | ||
+ | </ | ||
+ | |||
+ | === Troubleshootings on nginx === | ||
+ | * Job for nginx.service failed because the control process exited with error code | ||
+ | <cli> | ||
+ | # sudo systemctl status nginx.service | ||
+ | </ | ||
+ | |||
+ | * stop apache2 when running | ||
+ | <cli> | ||
+ | # sudo / | ||
+ | </ | ||
+ | |||
+ | <cli> | ||
+ | # sudo fuser -k 80/tcp | ||
+ | </ | ||
+ | |||
+ | * create .conf file: / | ||
+ | <sxh> | ||
+ | server | ||
+ | { | ||
+ | # | ||
+ | root / | ||
+ | index index.php; | ||
+ | |||
+ | location / { try_files $uri $uri/ @dokuwiki; } | ||
+ | |||
+ | location @dokuwiki | ||
+ | { | ||
+ | rewrite ^/ | ||
+ | rewrite ^/ | ||
+ | rewrite ^/ | ||
+ | rewrite ^/(.*) / | ||
+ | } | ||
+ | |||
+ | location ~ \.php$ | ||
+ | { | ||
+ | if (!-f $request_filename) { return 404; } | ||
+ | include fastcgi_params; | ||
+ | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
+ | fastcgi_param REDIRECT_STATUS 200; | ||
+ | fastcgi_pass unix:/ | ||
+ | } | ||
+ | |||
+ | location ~ / | ||
+ | { | ||
+ | deny all; | ||
+ | } | ||
+ | |||
+ | location ~ / | ||
+ | { | ||
+ | internal; | ||
+ | } | ||
+ | |||
+ | # | ||
+ | } | ||
+ | </ | ||
+ | === etc === | ||
+ | * version | ||
+ | <cli> | ||
+ | # sudo dpkg -l nginx | ||
+ | # nginx -v | ||
+ | </ | ||
+ | * /etc/nginx/ | ||
+ | <cli> | ||
+ | # sudo find / -name nginx.conf | ||
+ | </ | ||
+ | * test | ||
+ | <cli> | ||
+ | # netstat -lntp | ||
+ | </ | ||
+ | * if netstat doesn' | ||
+ | <cli> | ||
+ | # sudo apt install net-tools | ||
+ | </ | ||
+ | |||
+ | * force ssl | ||
+ | <sxh title:/ | ||
+ | # / | ||
+ | |||
+ | location ^~ / | ||
+ | allow all; | ||
+ | root / | ||
+ | default_type " | ||
+ | try_files $uri =404; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <sxh title:/ | ||
+ | server { | ||
+ | listen 80; | ||
+ | server_name wiki.theta5912.com; | ||
+ | #root / | ||
+ | |||
+ | include snippets/ | ||
+ | return 301 https:// | ||
+ | } | ||
+ | |||
+ | server { | ||
+ | # listen 80; | ||
+ | listen 443 ssl; | ||
+ | listen [::]:443 ssl; | ||
+ | |||
+ | server_name wiki.theta5912.com; | ||
+ | # ssl on; | ||
+ | |||
+ | ssl_certificate / | ||
+ | ssl_certificate_key / | ||
+ | |||
+ | root / | ||
+ | index index.php index.html index.html; | ||
+ | |||
+ | location / { | ||
+ | try_files $uri $uri/ @dokuwiki; | ||
+ | } | ||
+ | |||
+ | location @dokuwiki { | ||
+ | rewrite ^/ | ||
+ | rewrite ^/ | ||
+ | rewrite ^/ | ||
+ | rewrite ^/(.*) / | ||
+ | } | ||
+ | |||
+ | location ~ \.php$ { | ||
+ | # Caution: be sure the php7.2-fpm.sock matches your version | ||
+ | include snippets/ | ||
+ | fastcgi_pass unix:/ | ||
+ | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
+ | include fastcgi_params; | ||
+ | } | ||
+ | |||
+ | location ~ / | ||
+ | deny all; | ||
+ | } | ||
+ | |||
+ | } | ||
+ | | ||
+ | </ | ||
+ | |||
==== < | ==== < | ||
Line 298: | Line 456: | ||
<cli> | <cli> | ||
$ sudo certbot delete --cert-name {cert name} | $ sudo certbot delete --cert-name {cert name} | ||
+ | </ | ||
+ | |||
+ | * 이미 등록한 체인에 도메인을 추가 또는 삭제 | ||
+ | <cli> | ||
+ | $ sudo certbot --cert-name {domain address} -d {domain address} -d {domain address(sub)}... | ||
</ | </ | ||
Line 338: | Line 501: | ||
RewriteEngine On | RewriteEngine On | ||
RewriteCond %{HTTPS} off | RewriteCond %{HTTPS} off | ||
- | | + | |
</ | </ | ||
</ | </ | ||
Line 367: | Line 530: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// |