顯示具有 Nginx 標籤的文章。 顯示所有文章
顯示具有 Nginx 標籤的文章。 顯示所有文章

2023/10/27

透過CertBot取得AliCloud SSL憑證

要先去AliCloud申請AliyunDNSFullAccess權限


sudo apt update -y
sudo apt install snapd -y
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo snap install certbot-dns-aliyun
sudo snap set certbot trust-plugin-with-root=ok
sudo snap connect certbot:plugin certbot-dns-aliyun

# 將AliCloud DNS API and Secret 寫入到alicloud.ini
sudo echo "dns_aliyun_access_key = apikey" > /etc/letsencrypt/alicloud.ini
sudo echo "dns_aliyun_access_key_secret = secret" >> /etc/letsencrypt/alicloud.ini

sudo chmod 600 /etc/letsencrypt/alicloud.ini
sudo certbot certonly --authenticator=dns-aliyun --dns-aliyun-credentials='/etc/letsencrypt/alicloud.ini' -d "domain"

參考資料:
https://github.com/tengattack/certbot-dns-aliyun

2023/09/15

使用 Docker運行Vue project

專案結構如下:



常理來說要透過Nginx部屬,通常配置如下:


server {
    listen 80;
    listen [::]:80;
    root /usr/share/nginx/html;
    index index.html;
    server_name _;
    access_log /var/log/default_access_log;
    error_log  /var/log/default_error_log;

    location / {
        try_files $uri $uri/ /index.html?$args;
    }

    # Cache file
    location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        root /usr/share/nginx/html;
        expires 12h;
        add_header Pragma public;
        add_header Cache-Control "public, max-age=31536000";
    }
}

2023/06/30

Nginx 1.25.1 Release - http2 parameter deprecation

原本配置是這樣
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;


改為這樣就可以了
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;

2023/05/16

PHP Enable Opcache JIT

vim /etc/php/8.2/mods-available/opcache.ini
opcache.jit=on
opcache.jit=1205
opcache.jit_buffer_size=512M
參考資料:https://www.laruence.com/2020/06/27/5963.html

2023/05/12

Ubuntu 22.04 LTS Certbot 使用 CloudFlare 申請全域的 Let's Encrypt憑證

先輸入以下命令安裝套件
# Install CertBot
sudo apt update -y
sudo apt install snapd -y
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo apt install python-is-python3 python3-certbot-dns-cloudflare -y
進到CloudFlare所要取得SSL的Domain頁面,點擊Get your API token 編輯cf.ini
點擊Create Token

點擊Get started,啟用下列Pemission和選取要設定的Domain,點擊Continue to summary就會得到Token

2023/04/10

Nginx Proxy ESXi

upload有問題,登入上沒問題

server {
        listen 443;
        server_name exsi.domain;
        location / {
                if ($request_method = 'OPTIONS') {
                        add_header 'Access-Control-Allow-Origin' 'https://exsi.domain;
                        add_header 'Access-Control-Allow-Credentials' 'true';
                        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
                        add_header 'Access-Control-Max-Age' 1728000;
                        add_header 'Access-Control-Allow-Headers' 'VMware-CSRF-Token,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Cookie,SOAPAction';
                        add_header 'Content-Type' 'text/plain; charset=utf-8';
                        add_header 'Content-Length' 0;
                        return 204;
                }

                add_header 'Access-Control-Allow-Origin' 'https://exsi.domain';
                add_header 'Access-Control-Allow-Credentials' 'true';
                proxy_pass https://privateIP:443;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_ssl_verify off;
                proxy_ssl_session_reuse on;
                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
        }
}

2022/03/15

Nginx Reverse Proxy Synology DSM

server{
    server_name xxx.xxx.com;

    location / {

        # DSM Server
        proxy_pass https://ip:5001;
        # header變數,記錄使用者的 IP
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
        proxy_max_temp_file_size 0;
        # Surveillance
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
    }

    listen [::]:443 http2 ssl;
    listen 443 http2 ssl;

}

2020/09/21

Vue.js 解決Http 頁面緩存問題

每次更新後老闆都說看不到最新畫面,得清除緩存才能重新看到
在Nginx的conf加上下面幾行即可

	gzip on;
	gzip_static on;
	gzip_proxied any;
	gzip_vary on;
	gzip_comp_level 6;
	gzip_buffers 16 8k;
	gzip_http_version 1.1; 

2019/03/08

CentOS 7 安裝PhpRedisAdmin再Nginx


首先輸入下方命令安裝套件

# Install EPEL
yum install -y epel-release
# Update Package
yum update -y
# Install PHP PHP-FPM PHP-mbstring Nginx Redis
yum install -y git php php-fpm php-mbstring nginx redis


接著用Git下載PhpRedisAdmin

# Download PhpRedisAdmin
cd /var/www
git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
cd phpRedisAdmin
git clone https://github.com/nrk/predis.git vendor

修改Nginx

# 修改Nginx設定
vi /etc/nginx/nginx.conf
server_name localhost;

location / {
 root /var/www;
 index index.php;
}

location ~ \.php$ {
 root /var/www;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
}