Cấu hình hệ thống¶
This document describes basic steps to set up Odoo in production or on an internet-facing server. It follows installation, and is not generally necessary for a development systems that is not exposed on the internet.
Cảnh báo
If you are setting up a public server, be sure to check our Bảo mật recommendations!
dbfilter¶
Odoo là hệ thống multi-tenant: một hệ thống Odoo duy nhất có thể chạy và phục vụ nhiều phiên bản cơ sở dữ liệu. Nó cũng có khả năng tùy chỉnh cao và các tùy chỉnh (bắt đầu từ các phân hệ được tải) phụ thuộc vào “cơ sở dữ liệu hiện tại”.
Không có vấn đề gì khi làm việc với backend (máy khách web) với tư cách là người dùng công ty đã đăng nhập: có thể chọn cơ sở dữ liệu khi đăng nhập và tải các tùy chỉnh sau đó.
Tuy nhiên, lại có vấn đề đối với người dùng không đăng nhập (cổng thông tin, trang web) mà không ràng buộc với cơ sở dữ liệu nào: Odoo cần biết cơ sở dữ liệu nào nên được sử dụng để tải trang web hoặc thực hiện thao tác. Sẽ không thành vấn đề nếu không sử dụng multi-tenancy, vì chỉ có một cơ sở dữ liệu để sử dụng. Nhưng nếu có thể truy cập nhiều cơ sở dữ liệu, thì Odoo cần một quy tắc để biết nên sử dụng cơ sở dữ liệu nào.
That is one of the purposes of --db-filter
:
it specifies how the database should be selected based on the hostname (domain)
that is being requested. The value is a regular expression, possibly
including the dynamically injected hostname (%h
) or the first subdomain
(%d
) through which the system is being accessed.
For servers hosting multiple databases in production, especially if website
is used, dbfilter must be set, otherwise a number of features will not work
correctly.
Cấu hình mẫu¶
Chỉ hiển thị các cơ sở dữ liệu có tên bắt đầu bằng ‘mycompany’
in the configuration file set:
[options]
dbfilter = ^mycompany.*$
Show only databases matching the first subdomain after
www
: for example the database “mycompany” will be shown if the incoming request was sent towww.mycompany.com
ormycompany.co.uk
, but not forwww2.mycompany.com
orhelpdesk.mycompany.com
.
in the configuration file set:
[options]
dbfilter = ^%d$
Ghi chú
Setting a proper --db-filter
is an important part
of securing your deployment.
Once it is correctly working and only matching a single database per hostname, it
is strongly recommended to block access to the database manager screens,
and to use the --no-database-list
startup parameter to prevent listing
your databases, and to block access to the database management screens.
See also [security].
PostgreSQL¶
Theo mặc định, PostgreSQL chỉ cho phép kết nối qua UNIX socket và kết nối vòng lặp (từ “localhost”, cùng một máy mà máy chủ PostgreSQL được cài đặt).
UNIX socket is fine if you want Odoo and PostgreSQL to execute on the same machine, and is the default when no host is provided, but if you want Odoo and PostgreSQL to execute on different machines 1 it will need to listen to network interfaces 2, either:
Only accept loopback connections and use an SSH tunnel between the machine on which Odoo runs and the one on which PostgreSQL runs, then configure Odoo to connect to its end of the tunnel
Accept connections to the machine on which Odoo is installed, possibly over ssl (see PostgreSQL connection settings for details), then configure Odoo to connect over the network
Cấu hình mẫu¶
Cho phép kết nối tcp trên localhost
Cho phép kết nối tcp từ mạng 192.168.1.x
in /etc/postgresql/<YOUR POSTGRESQL VERSION>/main/pg_hba.conf
set:
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 192.168.1.0/24 md5
in /etc/postgresql/<YOUR POSTGRESQL VERSION>/main/postgresql.conf
set:
listen_addresses = 'localhost,192.168.1.2'
port = 5432
max_connections = 80
Cấu hình Odoo¶
Out of the box, Odoo connects to a local postgres over UNIX socket via port 5432. This can be overridden using the database options when your Postgres deployment is not local and/or does not use the installation defaults.
The packaged installers will automatically
create a new user (odoo
) and set it as the database user.
The database management screens are protected by the
admin_passwd
setting. This setting can only be set using configuration files, and is simply checked before performing database alterations. It should be set to a randomly generated value to ensure third parties can not use this interface.All database operations use the database options, including the database management screen. For the database management screen to work requires that the PostgreSQL user have
createdb
right.Users can always drop databases they own. For the database management screen to be completely non-functional, the PostgreSQL user needs to be created with
no-createdb
and the database must be owned by a different PostgreSQL user.Cảnh báo
người dùng PostgreSQL không được là siêu người dùng
Cấu hình mẫu¶
kết nối tới máy chủ PostgreSQL trên 192.168.1.2
cổng 5432
sử dụng một tài khoản người dùng ‘odoo’
với ‘pwd’ là mật khẩu
chỉ lọc db có tên bắt đầu bằng ‘mycompany’
in the configuration file set:
[options]
admin_passwd = mysupersecretpassword
db_host = 192.168.1.2
db_port = 5432
db_user = odoo
db_password = pwd
dbfilter = ^mycompany.*$
SSL giữa Odoo và PostgreSQL¶
Kể từ Odoo 11.0, bạn có thể thực thi kết nối ssl giữa Odoo và PostgreSQL. Trong Odoo, db_sslmode kiểm soát bảo mật ssl của kết nối với giá trị được chọn từ ‘disable’, ‘allow’, ‘prefer’, ‘require’, ‘verify-ca’ hoặc ‘verify-full’
Máy chủ tích hợp¶
Odoo tích hợp sẵn các máy chủ HTTP, cron và livechat, sử dụng đa luồng hoặc đa xử lý.
Máy chủ đa luồng là máy chủ đơn giản hơn, chủ yếu được sử dụng để phát triển và trình bày, và tương thích với nhiều hệ điều hành (bao gồm Windows). Một luồng mới được tạo ra cho mỗi yêu cầu HTTP mới, ngay cả đối với các kết nối tồn tại lâu dài như websocket. Các luồng daemon cron bổ sung cũng được tạo ra. Do hạn chế của Python (GIL), phần cứng không được tận dụng tối đa.
The multi-threaded server is the default server, also for docker containers. It is selected by
leaving the --workers
option out or setting it to 0
.
Máy chủ đa xử lý là máy chủ toàn diện được sử dụng chủ yếu cho production. Nó không chịu trách nhiệm về giới hạn Python (GIL) tương tự đối với việc sử dụng tài nguyên và do đó tận dụng tốt nhất phần cứng. Một nhóm worker được tạo khi khởi động máy chủ. Các yêu cầu HTTP mới được hệ điều hành xếp vào hàng đợi cho đến khi có worker sẵn sàng xử lý chúng. Một worker HTTP theo sự kiện bổ sung dành cho livechat được tạo ra trên một cổng thay thế. Worker cron bổ sung cũng được tạo ra. Trình thu thập quy trình có thể cấu hình sẽ giám sát việc sử dụng tài nguyên và có thể loại bỏ/khởi động lại các worker bị lỗi.
The multi-processing server is opt-in. It is selected by setting the --workers
option to a non-null integer.
Ghi chú
Vì được tùy chỉnh cao cho máy chủ Linux nên máy chủ đa xử lý không khả dụng trên Windows.
Tính toán số lượng worker¶
Nguyên tắc chung: (#CPU * 2) + 1
Cron worker cần CPU
1 worker ~= 6 người dùng đồng thời
tính toán kích thước bộ nhớ¶
Chúng tôi coi 20% yêu cầu là yêu cầu nặng, trong khi 80% là yêu cầu đơn giản hơn
Một worker nặng, khi tất cả các trường tính toán được thiết kế tốt, các yêu cầu SQL cũng được thiết kế tốt,… ước tính sẽ tiêu thụ khoảng 1GB RAM
Trong tình huống tương tự, một worker nhẹ hơn ước tính sẽ tiêu thụ khoảng 150MB RAM
RAM cần thiết = #worker * ( (tỷ lệ_worker_nhẹ * ước tính_ram_cho_worker_nhẹ) + (tỷ lệ_worker_nặng * ước tính_ram_cho_worker_nặng) )
LiveChat¶
In multi-processing, a dedicated LiveChat worker is automatically started and listens on
the --gevent-port
. By default, the HTTP requests will keep
accessing the normal HTTP workers instead of the LiveChat one. You must deploy a proxy in front of
Odoo and redirect incoming requests whose path starts with /websocket/
to the LiveChat worker.
You must also start Odoo in --proxy-mode
so it uses the real
client headers (such as hostname, scheme, and IP) instead of the proxy ones.
Cấu hình mẫu¶
Máy chủ với 4 core CPU, 8 luồng
60 người dung truy cập đồng thời
60 users / 6 = 10 <- theoretical number of worker needed
(4 * 2) + 1 = 9 <- theoretical maximal number of worker
Chúng tôi sẽ sử dụng 8 worker + 1 cho cron. Chúng tôi cũng sẽ sử dụng hệ thống giám sát để đo tải CPU và kiểm tra xem nó có nằm trong khoảng từ 7 đến 7,5 không.
RAM = 9 * ((0.8*150) + (0.2*1024)) ~= 3Go RAM for Odoo
in the configuration file:
[options]
limit_memory_hard = 1677721600
limit_memory_soft = 629145600
limit_request = 8192
limit_time_cpu = 600
limit_time_real = 1200
max_cron_threads = 1
workers = 8
HTTPS¶
Whether it’s accessed via website/web client or web service, Odoo transmits authentication information in cleartext. This means a secure deployment of Odoo must use HTTPS3. SSL termination can be implemented via just about any SSL termination proxy, but requires the following setup:
Enable Odoo’s
proxy mode
. This should only be enabled when Odoo is behind a reverse proxySet up the SSL termination proxy (Nginx termination example)
Set up the proxying itself (Nginx proxying example)
Proxy chấm dứt SSL của bạn cũng sẽ tự động chuyển hướng các kết nối không an toàn đến cổng an toàn
Cấu hình mẫu¶
Chuyển hướng yêu cầu http sang https
Yêu cầu proxy tới Odoo
in the configuration file set:
proxy_mode = True
in /etc/nginx/sites-enabled/odoo.conf
set:
#odoo server
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# http -> https
server {
listen 80;
server_name odoo.mycompany.com;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name odoo.mycompany.com;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
# SSL parameters
ssl_certificate /etc/ssl/nginx/server.crt;
ssl_certificate_key /etc/ssl/nginx/server.key;
ssl_session_timeout 30m;
ssl_protocols TLSv1.2;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
# log
access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;
# Redirect websocket requests to odoo gevent port
location /websocket {
proxy_pass http://odoochat;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
proxy_cookie_flags session_id samesite=lax secure; # requires nginx 1.19.8
}
# Redirect requests to odoo backend server
location / {
# Add Headers for odoo proxy mode
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_pass http://odoo;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
proxy_cookie_flags session_id samesite=lax secure; # requires nginx 1.19.8
}
# common gzip
gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
Nâng cao bảo mật HTTPS¶
Thêm header Strict-Transport-Security
vào tất cả yêu cầu để ngăn trình duyệt gửi yêu cầu HTTP thuần túy đến miền này. Bạn luôn cần duy trì dịch vụ HTTPS đang hoạt động với chứng chỉ hợp lệ trên miền này. Nếu không, người dùng của bạn sẽ thấy cảnh báo bảo mật hoặc hoàn toàn không thể truy cập.
Bắt buộc kết nối HTTPS trong năm cho mọi khách truy cập vào NGINX bằng dòng lệnh:
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
Additional configuration can be defined for the session_id
cookie. The Secure
flag can be added to ensure it is never transmitted over HTTP and SameSite=Lax
to prevent authenticated CSRF.
# requires nginx 1.19.8
proxy_cookie_flags session_id samesite=lax secure;
Odoo dưới dạng Ứng dụng WSGI¶
It is also possible to mount Odoo as a standard WSGI application. Odoo
provides the base for a WSGI launcher script as odoo-wsgi.example.py
. That
script should be customized (possibly after copying it from the setup directory) to correctly set the
configuration directly in odoo.tools.config
rather than through the
command-line or a configuration file.
Tuy nhiên, máy chủ WSGI sẽ chỉ hiển thị endpoint HTTP chính cho máy khách web, trang web và API dịch vụ web. Vì Odoo không còn kiểm soát việc tạo worker, nên không thể thiết lập worker cron hoặc livechat
Cron Worker¶
Starting one of the built-in Odoo servers next to the WSGI server is required to process cron jobs.
That server must be configured to only process crons and not HTTP requests using the
--no-http
cli option or the http_enable = False
configuration
file setting.
On Linux-like systems, using the multi-processing server over the multi-threading one is recommended
to benefit from better hardware usage and increased stability, i.e., using
the --workers=-1
and --max-cron-threads=n
cli options.
LiveChat¶
Using a gevent-compatible WSGI server is required for the correct operation of the live chat
feature. That server should be able to handle many simultaneous long-lived connections but doesn’t
need a lot of processing power. All requests whose path starts with /websocket/
should be
directed to that server. A regular (thread/process-based) WSGI server should be used for all other
requests.
The Odoo cron server can also be used to serve the live chat requests. Just drop
the --no-http
cli option from the cron server and make sure requests
whose path starts with /websocket/
are directed to this server, either on
the --http-port
(multi-threading server) or on
the --gevent-port
(multi-processing server).
Phục vụ tệp tĩnh và tệp đính kèm¶
Để thuận tiện cho việc phát triển, Odoo trực tiếp phục vụ tất cả các tệp tĩnh và tệp đính kèm trong các phân hệ. Điều này có thể không lý tưởng về hiệu suất, và các tệp tĩnh thường phải được phục vụ bởi một máy chủ HTTP tĩnh.
Phục vụ tệp tĩnh¶
Odoo static files are located in each module’s static/
folder, so static files can be served
by intercepting all requests to /MODULE/static/FILE
, and looking up the right module
(and file) in the various addons paths.
It is recommended to set the Content-Security-Policy: default-src 'none'
header on all images
delivered by the web server. It is not strictly necessary as users cannot modify/inject content
inside of modules’ static/
folder and existing images are final (they do not fetch new
resources by themselves). However, it is good practice.
Using the above NGINX (https) configuration, the following map
and location
blocks should be
added to serve static files via NGINX.
map $sent_http_content_type $content_type_csp {
default "";
~image/ "default-src 'none'";
}
server {
# the rest of the configuration
location @odoo {
# copy-paste the content of the / location block
}
# Serve static files right away
location ~ ^/[^/]+/static/.+$ {
# root and try_files both depend on your addons paths
root ...;
try_files ... @odoo;
expires 24h;
add_header Content-Security-Policy $content_type_csp;
}
}
The actual root
and try_files
directives are dependant on your installation, specifically on
your --addons-path
.
Example
Giả sử Odoo được cài đặt thông qua gói debian dành cho Community và Enterprise và :option:--addons-path <odoo-bin --addons-path>
là '/usr/lib/python3/dist-packages/odoo/addons'
.
Thì root
and try_files
như sau:
root /usr/lib/python3/dist-packages/odoo/addons;
try_files $uri @odoo;
Giả sử Odoo được cài đặt thông qua nguồn, cả kho lưu trữ git Community và Enterprise đều được sao chép trong :file:/opt/odoo/community
và :file:/opt/odoo/enterprise
tương ứng, và :option:--addons-path <odoo-bin --addons-path>
là '/opt/odoo/community/odoo/addons,/opt/odoo/community/addons,/opt/odoo/enterprise'
.
Thì root
and try_files
như sau:
root /opt/odoo;
try_files /community/odoo/addons$uri /community/addons$uri /enterprise$uri @odoo;
Phục vụ tệp đính kèm¶
Tệp đính kèm là các tệp được lưu trữ trong filestore mà Odoo quy định quyền truy cập. Không thể truy cập trực tiếp qua máy chủ web tĩnh vì việc truy cập chúng đòi hỏi nhiều lần tra cứu trong cơ sở dữ liệu để xác định nơi lưu trữ tệp và liệu người dùng hiện tại có thể truy cập chúng hay không.
Nevertheless, once the file has been located and the access rights verified by Odoo, it is a good
idea to serve the file using the static web server instead of Odoo. For Odoo to delegate serving
files to the static web server, the X-Sendfile (apache) or
X-Accel (nginx) extensions
must be enabled and configured on the static web server. Once it is set up, start Odoo with the
--x-sendfile
CLI flag (this unique flag is used for both
X-Sendfile and X-Accel).
Ghi chú
Tiện ích mở rộng X-Sendfile dành cho apache (và các máy chủ web tương thích) không yêu cầu bất kỳ cấu hình bổ sung nào.
Tiện ích mở rộng X-Accel cho NGINX yêu cầu cấu hình bổ sung sau:
location /web/filestore { internal; alias /path/to/odoo/data-dir/filestore; }
In case you don’t know what is the path to your filestore, start Odoo with the
--x-sendfile
option and navigate to the/web/filestore
URL directly via Odoo (don’t navigate to the URL via NGINX). This logs a warnings, the message contains the configuration you need.
Bảo mật¶
Trước hết, bạn nên nhớ rằng bảo mật hệ thống thông tin là một quá trình liên tục, không phải là một thao tác diễn ra một lần. Hãy luôn đảm bảo tính bảo mật của từng chi tiết nhỏ trong hệ thống của bạn.
Vì vậy, mong rằng bạn không coi phần này là danh sách cuối cùng về các biện pháp sẽ ngăn ngừa mọi vấn đề bảo mật. Nó chỉ có mục đích tóm tắt những điều quan trọng hàng đầu mà bạn nên đưa vào kế hoạch bảo mật của mình. Phần còn lại sẽ đến từ các biện pháp bảo mật tốt nhất cho hệ điều hành và bản phân phối của bạn, các biện pháp tốt nhất về người dùng, mật khẩu và quản lý kiểm soát truy cập,…
Khi triển khai máy chủ kết nối Internet, hãy nhớ cân nhắc các chủ đề liên quan đến bảo mật sau:
Always set a strong super-admin admin password, and restrict access to the database management pages as soon as the system is set up. See db_manager_security.
Chọn tên đăng nhập duy nhất và mật khẩu mạnh cho tất cả tài khoản quản trị viên trên tất cả cơ sở dữ liệu. Không sử dụng ‘admin’ làm tên đăng nhập. Không sử dụng những tên đăng nhập đó cho các hoạt động thường xuyên mà chỉ sử dụng để kiểm soát/quản lý cài đặt. Không bao giờ sử dụng bất kỳ mật khẩu mặc định nào như admin/admin, ngay cả đối với cơ sở dữ liệu kiểm thử/staging.
Không cài đặt dữ liệu demo trên các máy chủ kết nối internet. Cơ sở dữ liệu có dữ liệu demo chứa tên đăng nhập và mật khẩu mặc định có thể được sử dụng để xâm nhập vào hệ thống của bạn và gây ra sự cố nghiêm trọng, ngay cả trên hệ thống staging/phát triển.
Use appropriate database filters (
--db-filter
) to restrict the visibility of your databases according to the hostname. See dbfilter. You may also use-d
to provide your own (comma-separated) list of available databases to filter from, instead of letting the system fetch them all from the database backend.Once your
db_name
anddbfilter
are configured and only match a single database per hostname, you should setlist_db
configuration option toFalse
, to prevent listing databases entirely, and to block access to the database management screens (this is also exposed as the--no-database-list
command-line option)Make sure the PostgreSQL user (
--db_user
) is not a super-user, and that your databases are owned by a different user. For example they could be owned by thepostgres
super-user if you are using a dedicated non-privilegeddb_user
. See also setup/deploy/odoo.Keep installations updated by regularly installing the latest builds, either via GitHub or by downloading the latest version from https://www.odoo.com/page/download or http://nightly.odoo.com
Configure your server in multi-process mode with proper limits matching your typical usage (memory/CPU/timeouts). See also builtin_server.
Run Odoo behind a web server providing HTTPS termination with a valid SSL certificate, in order to prevent eavesdropping on cleartext communications. SSL certificates are cheap, and many free options exist. Configure the web proxy to limit the size of requests, set appropriate timeouts, and then enable the
proxy mode
option. See also https_proxy.Nếu bạn cần cho phép truy cập SSH từ xa vào máy chủ của mình, hãy đảm bảo đặt mật khẩu mạnh cho tất cả tài khoản, không chỉ
root
. Chúng tôi khuyến khích tắt hoàn toàn xác thực bằng mật khẩu và chỉ cho phép xác thực bằng mã khóa công khai. Ngoài ra, hãy cân nhắc hạn chế quyền truy cập qua VPN, chỉ cho phép các IP đáng tin cậy trong tường lửa và/hoặc chạy hệ thống phát hiện tấn công brute-force nhưfail2ban
hoặc tương đương.Consider installing appropriate rate-limiting on your proxy or firewall, to prevent brute-force attacks and denial of service attacks. See also login_brute_force for specific measures.
Nhiều nhà cung cấp mạng cung cấp dịch vụ giảm thiểu tự động cho các cuộc Tấn công Từ chối Dịch vụ Phân tán (DDOS), nhưng đây thường là dịch vụ tùy chọn, vì vậy bạn nên tham khảo với nhà cung cấp của mình.
Nếu có thể, hãy luôn lưu trữ các phiên bản demo/kiểm thử/staging công khai của bạn trên các máy khác với máy production. Và áp dụng các biện pháp phòng ngừa bảo mật tương tự như đối với production.
If your public-facing Odoo server has access to sensitive internal network resources or services (e.g. via a private VLAN), implement appropriate firewall rules to protect those internal resources. This will ensure that the Odoo server cannot be used accidentally (or as a result of malicious user actions) to access or disrupt those internal resources. Typically this can be done by applying an outbound default DENY rule on the firewall, then only explicitly authorizing access to internal resources that the Odoo server needs to access. Systemd IP traffic access control may also be useful to implement per-process network access control.
Nếu máy chủ Odoo công khai của bạn nằm sau Tường lửa ứng dụng web, bộ cân bằng tải, dịch vụ bảo vệ DDoS minh bạch (như CloudFlare) hoặc một thiết bị cấp độ mạng tương tự, bạn có thể nên tránh truy cập trực tiếp vào hệ thống Odoo. Nhìn chung, rất khó để giữ bí mật địa chỉ IP endpoint của máy chủ Odoo của bạn. Ví dụ: chúng có thể xuất hiện trong nhật ký máy chủ web khi truy vấn hệ thống công cộng hoặc trong tiêu đề email từ Odoo. Trong tình huống như vậy, bạn có thể nên cấu hình tường lửa của mình để ngăn chặn việc truy cập công khai endpoint, trừ truy cập từ các địa chỉ IP cụ thể của dịch vụ WAF, cân bằng tải hoặc proxy của bạn. Các nhà cung cấp dịch vụ như CloudFlare thường duy trì danh sách công khai các dải địa chỉ IP của họ cho mục đích này.
Nếu bạn đang lưu trữ nhiều khách hàng, hãy cô lập dữ liệu và tệp khách hàng khỏi nhau bằng cách sử dụng container hoặc các kỹ thuật “rào chắn” thích hợp.
Tạo sao lưu hàng ngày cho cơ sở dữ liệu và dữ liệu filestore của bạn và sao chép chúng vào một máy chủ lưu trữ từ xa mà chính máy chủ đó không thể truy cập được.
Triển khai Odoo trên Linux được khuyến khích hơn là Windows. Tuy nhiên, nếu bạn vẫn chọn triển khai trên nền tảng Windows, bạn nên tiến hành đánh giá bảo mật toàn diện cho máy chủ và phạm vi hướng dẫn này không bao gồm hoạt động đó.
Chặn các Cuộc Tấn công Brute Force¶
Với các triển khai kết nối internet, những cuộc tấn công brute force vào mật khẩu người dùng rất phổ biến và không nên bỏ qua mối đe dọa này đối với các máy chủ Odoo. Odoo tạo một mục nhật ký bất cứ khi nào một nỗ lực đăng nhập được thực hiện và báo cáo kết quả (thành công hay không thành công) cùng với mục tiêu đăng nhập và IP nguồn.
Mục nhật ký có dạng như sau.
Failed login:
2018-07-05 14:56:31,506 24849 INFO db_name odoo.addons.base.res.res_users: Login failed for db:db_name login:admin from 127.0.0.1
Successful login:
2018-07-05 14:56:31,506 24849 INFO db_name odoo.addons.base.res.res_users: Login successful for db:db_name login:admin from 127.0.0.1
Các nhật ký này có thể dễ dàng được phân tích bởi hệ thống phòng chống xâm nhập như fail2ban
.
For example, the following fail2ban filter definition should match a failed login:
[Definition]
failregex = ^ \d+ INFO \S+ \S+ Login failed for db:\S+ login:\S+ from <HOST>
ignoreregex =
Bạn có thể sử dụng với định nghĩa rào chắn để chặn IP tấn công trên HTTP(S).
Here is what it could look like for blocking the IP for 15 minutes when 10 failed login attempts are detected from the same IP within 1 minute:
[odoo-login]
enabled = true
port = http,https
bantime = 900 ; 15 min ban
maxretry = 10 ; if 10 attempts
findtime = 60 ; within 1 min /!\ Should be adjusted with the TZ offset
logpath = /var/log/odoo.log ; set the actual odoo log path here
Bảo mật Trình Quản lý Cơ sở Dữ liệu¶
setup/deploy/odoo mentioned admin_passwd
in passing.
Thiết lập này được sử dụng trên tất cả các màn hình quản lý cơ sở dữ liệu (để tạo, xóa, kết xuất hoặc khôi phục cơ sở dữ liệu).
If the management screens must not be accessible at all, you should set list_db
configuration option to False
, to block access to all the database selection and
management screens.
Cảnh báo
Chúng tôi khuyến nghị bạn tắt Trình quản lý cơ sở dữ liệu cho mọi hệ thống có kết nối internet! Nó được dùng làm công cụ phát triển/demo để bạn có thể dễ dàng tạo và quản lý cơ sở dữ liệu nhanh chóng; nhưng không được thiết kế để sử dụng trong production và thậm chí có thể làm lộ các tính năng nguy hiểm cho kẻ tấn công. Nó cũng không có khả năng xử lý cơ sở dữ liệu lớn và có thể kích hoạt giới hạn bộ nhớ.
Trên các hệ thống production, quản trị viên hệ thống luôn là người thực hiện hoạt động quản lý cơ sở dữ liệu, bao gồm việc cung cấp cơ sở dữ liệu mới và sao lưu tự động.
Be sure to setup an appropriate db_name
parameter
(and optionally, dbfilter
too) so that the system can determine the target database
for each request, otherwise users will be blocked as they won’t be allowed to choose the
database themselves.
If the management screens must only be accessible from a selected set of machines,
use the proxy server’s features to block access to all routes starting with /web/database
except (maybe) /web/database/selector
which displays the database-selection screen.
If the database-management screen should be left accessible, the
admin_passwd
setting must be changed from its admin
default: this
password is checked before allowing database-alteration operations.
Nó phải được lưu trữ an toàn và phải được tạo ngẫu nhiên, ví dụ:
$ python3 -c 'import base64, os; print(base64.b64encode(os.urandom(24)))'
tạo ra một chuỗi ký tự giả ngẫu nhiên có thể in được gồm 32 ký tự.
Đặt lại Mật khẩu Chính¶
Có thể xảy ra trường hợp mật khẩu chính bị thất lạc hoặc bị xâm phạm và cần phải đặt lại. Quy trình sau đây dành cho quản trị viên hệ thống của cơ sở dữ liệu Odoo on-premise, nêu chi tiết cách đặt lại và mã hóa lại mật khẩu chính theo cách thủ công.
Xem thêm
For more information about changing an Odoo.com account password, see this documentation: odoocom/change_password.
Khi tạo cơ sở dữ liệu on-premise mới, một mật khẩu chính ngẫu nhiên sẽ được tạo. Odoo khuyến khích sử dụng mật khẩu này để bảo mật cơ sở dữ liệu. Mật khẩu này được triển khai theo mặc định, do đó bất kỳ triển khai Odoo on-premise nào đều có một mật khẩu chính an toàn.
Cảnh báo
Khi tạo cơ sở dữ liệu Odoo on-premise và chưa đặt mật khẩu này để bảo mật cơ sở dữ liệu, thì bất kỳ ai trên internet cũng có thể truy cập cài đặt.
Mật khẩu chính được xác định trong tệp cấu hình Odoo (odoo.conf
hoặc odoorc
(tệp ẩn)). Cần có mật khẩu chính Odoo để sửa đổi, tạo hoặc xóa cơ sở dữ liệu thông qua giao diện người dùng đồ họa (GUI).
Xác định vị trí tệp cấu hình¶
Đầu tiên, mở tệp cấu hình Odoo (odoo.conf
hoặc odoorc
(tệp ẩn)).
Tệp cấu hình nằm tại: c:\\ProgramFiles\\Odoo{VERSION}\\server\\odoo.conf
Tùy thuộc vào cách Odoo được cài đặt trên máy Linux, tệp cấu hình sẽ nằm ở một trong hai vị trí khác nhau:
Cài đặt gói:
/etc/odoo.conf
Cài đặt nguồn:
~/.odoorc
Thay đổi mật khẩu cũ¶
Sau khi mở tệp thích hợp, hãy tiến hành sửa đổi mật khẩu cũ trong tệp cấu hình thành mật khẩu tạm thời.
Sau khi định vị được tệp cấu hình, hãy mở tệp đó bằng (:abbr:GUI (giao diện người dùng đồ họa)
). Bạn có thể thực hiện việc này chỉ bằng cách nhấp đúp vào tệp. Sau đó, :abbr:GUI (giao diện người dùng đồ họa)
mặc định trên thiết bị sẽ mở tệp.
Tiếp theo, sửa đổi dòng mật khẩu chính, ví dụ admin_passwd = $pbkdf2-sha…
thành admin_passwd = newpassword1234
. Mật khẩu này có thể được đặt bất kỳ, miễn là nó được lưu tạm thời. Hãy nhớ sửa đổi tất cả ký tự sau dấu =
.
Example
Dòng mật khẩu chính như sau: admin_passwd = $pbkdf2-sh39dji295.59mptrfW.9z6HkA$w9j9AMVmKAP17OosCqDxDv2hjsvzlLpF8Rra8I7p/b573hji540mk/.3ek0lg%kvkol6k983mkf/40fjki79m
Dòng được sửa đổi sẽ có dạng: admin_passwd = newpassword1234
Sửa đổi dòng mật khẩu chính bằng lệnh Unix được trình bày chi tiết dưới đây.
Kết nối với thiết bị đầu cuối của máy chủ Odoo qua giao thức Secure Shell (SSH) và chỉnh sửa tệp cấu hình. Để chỉnh sửa tệp cấu hình, hãy nhập lệnh sau: :command:sudo nano /etc/odoo.conf
Sau khi mở tệp cấu hình, sửa đổi dòng mật khẩu chính admin_passwd = $pbkdf2-sha…
thành admin_passwd = newpassword1234
. Mật khẩu này có thể được đặt bất kỳ, miễn là nó được lưu tạm thời. Hãy nhớ sửa đổi tất cả ký tự sau dấu =
.
Example
Dòng mật khẩu chính như sau: admin_passwd = $pbkdf2-sh39dji295.59mptrfW.9z6HkA$w9j9AMVmKAP17OosCqDxDv2hjsvzlLpF8Rra8I7p/b573hji540mk/.3ek0lg%kvkol6k983mkf/40fjki79m
Dòng được sửa đổi sẽ có dạng: admin_passwd = newpassword1234
Quan trọng
Điều quan trọng là phải đổi mật khẩu thành mật khẩu khác, thay vì kích hoạt đặt lại mật khẩu mới bằng cách thêm dấu chấm phẩy ;
vào đầu dòng. Điều này đảm bảo cơ sở dữ liệu được bảo mật trong suốt quá trình đặt lại mật khẩu.
Khởi động lại máy chủ Odoo¶
Sau khi đặt mật khẩu tạm thời, bạn phải khởi động lại máy chủ Odoo.
Để khởi động lại máy chủ Odoo, trước tiên, hãy nhập services
vào thanh :guilabel:Tìm kiếm
của Windows. Sau đó, chọn ứng dụng :guilabel:Dịch vụ
và cuộn xuống dịch vụ :guilabel:Odoo
.
Tiếp theo, nhấp chuột phải vào :guilabel:Odoo
và chọn :guilabel:Khởi động
hoặc :guilabel:Khởi động lại
. Hành động này sẽ khởi động lại máy chủ Odoo theo cách thủ công.
Khởi động lại máy chủ Odoo bằng cách nhập lệnh: :command:sudo service odoo15 restart
Ghi chú
Thay đổi số sau odoo
cho phù hợp với phiên bản mà máy chủ đang chạy.
Sử dụng giao diện web để mã hóa lại mật khẩu¶
Đầu tiên, đi đến /web/database/manager
hoặc http://server_ip:port/web/database/manager
trong trình duyệt.
Ghi chú
Thay thế server_ip
bằng địa chỉ IP của cơ sở dữ liệu. Thay thế port
bằng cổng được đánh số mà cơ sở dữ liệu có thể truy cập được.
Next, click Set Master Password, and type in the previously-selected temporary password into the Master Password field. Following this step, type in a New Master Password. The New Master Password is hashed (or encrypted), once the Continue button is clicked.
Đến đây thì mật khẩu đã được đặt lại thành công và phiên bản hash của mật khẩu mới sẽ xuất hiện trong tệp cấu hình.
Xem thêm
For more information on Odoo database security, see this documentation: db_manager_security.
Các trình duyệt được hỗ trợ¶
Odoo hỗ trợ tất cả trình duyệt máy tính để bàn và thiết bị di động phổ biến hiện có trên thị trường, miễn là chúng được nhà phát hành hỗ trợ.
Đây là các trình duyệt được hỗ trợ:
Google Chrome
Mozilla Firefox
Microsoft Edge
Apple Safari
Cảnh báo
Hãy đảm bảo trình duyệt của bạn là phiên bản mới và vẫn được nhà phát hành hỗ trợ trước khi gửi báo cáo lỗi.
Ghi chú
Since Odoo 13.0, ES6 is supported. Therefore, IE support is dropped.
- 1
để nhiều cài đặt Odoo sử dụng cùng một cơ sở dữ liệu PostgreSQL hoặc cung cấp nhiều tài nguyên điện toán hơn cho cả hai phần mềm.
- 2
technically a tool like socat can be used to proxy UNIX sockets across networks, but that is mostly for software which can only be used over UNIX sockets
- 3
or be accessible only over an internal packet-switched network, but that requires secured switches, protections against ARP spoofing and precludes usage of WiFi. Even over secure packet-switched networks, deployment over HTTPS is recommended, and possible costs are lowered as “self-signed” certificates are easier to deploy on a controlled environment than over the internet.