Cài đặt Reverse Proxy để truy cập Odoo16 qua tên miền riêng

Để có thể truy cập Odoo bằng một tên miền, thay vì nhập địa chỉ IP và số cổng trong trình duyệt web của bạn, chúng tôi cần một máy chủ web. Trong hướng dẫn này, chúng tôi sẽ cài đặt và sử dụng Nginx. Chạy lệnh sau để cài đặt nó

sudo apt update
sudo apt install nginx

Buoc 2: Tuong lua

sudo ufw app list

OutputAvailable applications:
  Nginx Full
  Nginx HTTP
  Nginx HTTPS
  OpenSSH
Luu y quan trong o buoc nay!
Can phai check trang thai ufw dang chay hay khong
sudo ufw status
va 1 luu y nua, can phai cho phep nginx full de chay ca https
Cho phep ca OpenSSH de remote ssh tu xa!
sudo ufw allow 'Nginx Full'
sudo ufw allow 'OpenSSH'
Neu ufw dang inactive
sudo ufw enable
Check status the nay la oki

root@localhost:~# sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
Nginx Full                 ALLOW       Anywhere
OpenSSH                    ALLOW       Anywhere
Nginx Full (v6)            ALLOW       Anywhere (v6)
OpenSSH (v6)               ALLOW       Anywhere (v6)

Cho phep nginx khoi dong cung he thong
sudo systemctl enable nginx
Khoi dong nginx
sudo systemctl start nginx
Cac cau lenh thuong dung voi nginx
sudo systemctl start nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo systemctl disable nginx
sudo systemctl enable nginx

Buoc 3 Cau hinh nginx cho ten mien

Cau hinh nginx cho tung ten mien se duoc luu tai thu muc /etc/nginx/sites-available

Huong dan tren duoi day cho ten mien bbx.com.vn

sudo nano /etc/nginx/sites-available/bbx.com.vn.conf

Noi dung file mac dinh the nay

server {
    listen       80;
    listen       [::]:80;
    server_name  bbx.com.vn;

    access_log  /var/log/nginx/odoo.access.log;
    error_log   /var/log/nginx/odoo.error.log;

    location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-Host $host;
      proxy_set_header X-Forwarded-Proto https;
      proxy_pass http://localhost:8069;
  }
}

Link sang thu muc /etc/nginx/sites-enabled/

sudo ln -s /etc/nginx/sites-available/bbx.com.vn.conf /etc/nginx/sites-enabled/

Kiem tra lai cu phap nginx oki chua

sudo nginx -t

The nay la oki

root@localhost:~# sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

sudo systemctl reload nginx.service

Hoac sudo systemctl reload nginx

Buoc 4: Cai dat Certbot va cai dat TLS Certificates de truy cap ten mien qua https

sudo apt install certbot python3-certbot-nginx

sudo certbot –nginx -d bbx.com.vn

Nhap email, Y Y de xac nhan

Thong bao the nay la oki:

Account registered.
Requesting a certificate for bbx.com.vn

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/bbx.com.vn/fullchain.pem
Key is saved at: /etc/letsencrypt/live/bbx.com.vn/privkey.pem
This certificate expires on 2023-07-01.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for bbx.com.vn to /etc/nginx/sites-enabled/bbx.com.vn.conf
Congratulations! You have successfully enabled HTTPS on https://bbx.com.vn
We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.


If you like Certbot, please consider supporting our work by:

  • Donating to ISRG / Let’s Encrypt: https://letsencrypt.org/donate
  • Donating to EFF: https://eff.org/donate-le

Kiem tra lai file config

sudo nano /etc/nginx/sites-available/bbx.com.vn.conf

Se thay co cac thong so duoc them vao de chay ssl

listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/bbx.com.vn/fullchain.pem; # managed b>
ssl_certificate_key /etc/letsencrypt/live/bbx.com.vn/privkey.pem; # managed>
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


Comments

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *