Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

Odoo 18 (from source) on Ubuntu running behind nginx - Odoo logs not showing real IP address

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
nginxNGINX
2 Trả lời
4756 Lượt xem
Ảnh đại diện
M S

Hi,

I have Odoo 18 (using source) running behind Nginx successfully. For some reasons, the odoo logs do not show the real IP address for users. Nginx is configured to forward the IP (X-Forwarded-For) to backend and odoo config has proxy_mode set to true. I have done some searching on the Internet already and couldn't find anything in particular that may fix this issue.

Odoo log entry:

2025-05-01 03:39:19,437 4086 INFO odoo odoo.addons.base.models.res_users: Login failed for db:odoo login:oodf from 127.0.0.1

I am providing the nginx and odoo config files below as well below.

Nginx config

# Odoo servers
geo $limit {
  default 1;
  1.2.3.4/22 0;
  1.2.3.4/24 0;
  1.2.3.4/24 0;
  1.2.3.4/24 0;
  1.2.3.4/20 0;
}

map $limit $limit_key {
        0 "";
        1 $binary_remote_addr;
}

limit_req_zone $limit_key zone=general:10m rate=200r/m;

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 mywebsite.example.com;
  include snippets/letsencrypt.conf;
  return 301 https://mywebsite.example.com$request_uri;
}
# WWW -> NON WWW
server {
    listen 443 ssl http2;
    server_name www.mywebsite.example.com;
    ssl_certificate /etc/letsencrypt/live/mywebsite.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mywebsite.example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/mywebsite.example.com/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;

    return 301 https://mywebsite.example.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name mywebsite.example.com;
    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;

    # Proxy headers
    proxy_set_header X-Forwarded-Host $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;

    # SSL parameters
    ssl_certificate /etc/letsencrypt/live/mywebsite.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mywebsite.example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/mywebsite.example.com/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;


    # Increase client_max_body_size to your required ammount
    client_max_body_size 20M;

    # log files
    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" always;
    proxy_cookie_flags session_id samesite=lax secure;
    proxy_redirect off;
  }

  # Handle longpoll requests
    location /longpolling {
        proxy_pass http://odoochat;
    }

    # Redirect requests to odoo backend server
    location / {
            # Add Headers for odoo proxy mode

            limit_req zone=general burst=50 nodelay;
            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;

            # Enable HSTS
            add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
            # requires nginx 1.19.8
            proxy_cookie_flags session_id samesite=lax secure;
    }

    # Cache static files
    location ~*/web/static/ {
        limit_req zone=general;
        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_cache_valid 200 90m;
        proxy_buffering on;
        expires 864000;
        proxy_pass http://odoo;
        #add_header Content-Security-Policy $content_type_csp;
    }

    # Gzip
    gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
    gzip on;
} ​

Odoo Config file

[DEFAULT]
admin_passwd = abcdefghijklmn
db_host = False
db_port = False
db_user = odoo
db_password = False
addons_path = /opt/odoo/odoo/addons,/opt/odoo/odoo-custom-addons
proxy_mode = true
list_db = False ​ ​

Does anyone have any ideas as to what could the problem be?


Thanks,

Mohammad

0
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
M S
Tác giả Câu trả lời hay nhất

Thanks for the suggestion. 

Unfortunately, changing "true" to "True" in the odoo config made no difference. Yes, I restarted the services as mentioned. Just  to be sure, I also rebooted the server after making the changes but odoo log is still showing 127.0.0.1

[DEFAULT]
admin_passwd = xxxxxxxxxxxx
db_host = False
db_port = False
db_user = odoo
db_password = False
addons_path = /opt/odoo/odoo/addons,/opt/odoo/odoo-custom-addons
proxy_mode = True
list_db = False

2025-05-03 10:13:23,229 1536 INFO odoo werkzeug: 127.0.0.1 - - [03/May/2025 10:13:23] "POST /web/login HTTP/1.0" 200 - 6 0.010 0.008
2025-05-03 10:13:23,369 1536 INFO odoo werkzeug: 127.0.0.1 - - [03/May/2025 10:13:23] "GET /web/binary/company_logo HTTP/1.0" 304 - 2 0.001 0.002
2025-05-03 10:13:23,728 1536 INFO odoo werkzeug: 127.0.0.1 - - [03/May/2025 10:13:23] "GET /web/webclient/translations/1746267203712 HTTP/1.0" 200 - 2 0.001 0.002
0
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Takahiro SUNAGA
Câu trả lời hay nhất

Hi, 
Shouldn't "proxy_mode = true" instead of "proxy_mode = True"?
Try restarting the service after the fix.

Summary of Steps:

  1. Ensure proxy_mode = True is under the [options] section in odoo.conf.
  2. Restart the Odoo service (sudo systemctl restart odoo).
  3. Verify Nginx configuration (sudo nginx -t).
  4. Reload the Nginx service (sudo systemctl reload nginx).
  5. Check Nginx access logs to confirm it sees the real client IP.
  6. Try logging into Odoo again and check the Odoo logs.

0
Ảnh đại diện
Huỷ bỏ
Takahiro SUNAGA

Hi, How about using the `set_real_ip_from` directive to solve this?
Here's the documentation:
https://nginx.org/en/docs/http/ngx_http_realip_module.html#set_real_ip_from

Best regards,

Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
Nginx odoo 16 proxy and method not allowed 405
nginx
Ảnh đại diện
Ảnh đại diện
2
thg 9 24
3734
I'm trying to edit sites-available and sites-enabled - Configuration Builtin server Odoo 17
NGINX
Ảnh đại diện
0
thg 7 24
1613
How can I setup odoo on a path with nginx
nginx
Ảnh đại diện
Ảnh đại diện
1
thg 5 24
4595
Nginx with Odoo configuration: host not found in upstream
nginx
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 5 24
15955
Reverse Proxy Converts URL to Garbage Đã xử lý
NGINX
Ảnh đại diện
Ảnh đại diện
1
thg 7 23
5898
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now