コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

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

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

Unable to create HTTPS Stripe webhook with Nginx reverse proxy

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
webhookstripengnix
2 返信
4776 ビュー
アバター
Liu

Does anyone know how to have nginx reverse proxy communicate to Odoo so it uses https for stripe webhooks instead of http?


I have a Odoo docker container running over https with an nginx container as a reverse proxy. Everything works for the most part except when I try to generate or use the Stripe payment webhook Odoo is creating it with http instead of https protocol. While this technically is working, it should be secured. 


It seems Odoo is getting the http protocol from the proxy_pass line in the nginx configuration, where I'm using http to pass traffic to the Odoo container. 


I'm not a python developer, but I think it is related to this chunk of code in payment_provider code on GitHub.  I wasn't able to figure out why it wasn't working based on that though.


My nginx configuration file is below to show what I have currently after swapping out the hostname with comments in areas where I was trying to pass https protocol, but failed. Appreciate any help, hints or feedback.


## Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl {
  default off;
  https on;
}

upstream test-stream {
   server odoo:8069;
}

server {
    listen      80;
    listen [::]:80;
    server_name example.com www.example.com;

    # ACME-challenge used by Certbot for Let's Encrypt
    location ^~ /.well-known/acme-challenge/ {
      root /var/www/certbot;
    }

    location / {
        rewrite ^ https://$host$request_uri? permanent;
    }
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name example.com;

    # removed cert, logs, and etc. related lines for brevity

    # Tried this line before the location block to pass https, not working
    proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;

    location / {
          proxy_pass http://test-stream;
          proxy_set_header Host $host;
 
   #####################
    # Tried the following lines to pass https, but none worked
    ####################      
          proxy_set_header Scheme https;
          proxy_set_header X-Forwarded-Scheme https;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-Forwarded-Proto https;

   }

}
2
アバター
破棄
アバター
Porta Capena
最善の回答

Hi Liu!

Is your webhook addres correct? When I was testing webhook it was saying, that there is an error because URL is not publicly visible. I had the following error in odoo logs:

ERROR  odoo.addons.payment_stripe.models.payment_provider: invalid API request at https://api.stripe.com/v1/webhook_endpoints with data 
{'url': 'http://localhost:8079/payment/stripe/webhook', 
'enabled_events[]': ['payment_intent.amount_capturable_updated', 
'payment_intent.succeeded', 'payment_intent.payment_failed', 
'setup_intent.succeeded', 'charge.refunded', 'charge.refund.updated'], 
'api_version': '2019-05-16'} 

Also, cancel_url and success_url in the stripe request had localhost as a domain.

What worked for me:

1. Add the following flag in the odoo config file:

[options]
proxy_mode = True

2. Add this header in the nginx config (I added it in the 'location' block):

proxy_set_header X-Forwarded-Host $host;


Explanation: 

When you dig further into payment_provider method (I guess this is the one that you provided in the link, but it does not work for me), you will see that it takes url from url_root method in the Werkzeug's BaseRequest class:


@cached_property
def url_root(self):
"""The full URL root (with hostname), this is the application
root as IRI.
See also: :attr:`trusted_hosts`.
"""
return get_current_url(self.environ, True, trusted_hosts=self.trusted_hosts)


Jumping next, werkzeug will take this url from "HTTP_HOST" key in the ENVIRON dictionary, the WSGI environment configuration. 

def get_host(environ, trusted_hosts=None):
""":param environ: The WSGI environment to get the host from."""
if "HTTP_HOST" in environ:
rv = environ["HTTP_HOST"]
if environ["wsgi.url_scheme"] == "http" and rv.endswith(":80"):
rv = rv[:-3]
elif environ["wsgi.url_scheme"] == "https" and rv.endswith(":443"):
rv = rv[:-4]
else:
rv = environ["SERVER_NAME"]
if (environ["wsgi.url_scheme"], environ["SERVER_PORT"]) not in (
("https", "443"),
("http", "80"),
):
rv += ":" + environ["SERVER_PORT"]
return rv

(irrelevant code omited)

Now we are getting to somewhere. As Werkzeug team says:

When an application is running behind a proxy server, WSGI may see the request as coming from that server rather than the real client. Proxies set various headers to track where the request actually came from.

They also provide a fix for it:
https://werkzeug.palletsprojects.com/en/2.3.x/middleware/proxy_fix/

But what can we do with this? Let's search the odoo code. Then we will find this:

if odoo.tools.config['proxy_mode'] and environ.get("HTTP_X_FORWARDED_HOST"):
# The ProxyFix middleware has a side effect of updating the
# environ, see https://github.com/pallets/werkzeug/pull/2184
def fake_app(environ, start_response):
return []
def fake_start_response(status, headers):
return
ProxyFix(fake_app)(environ, fake_start_response)

Bingo! 

I hope this will help, if not you then somebody in the future ;)

BR, Kajetan Dowda-Tchórzewski.

0
アバター
破棄
Liu
著作者

Thank you for taking the time to not only give the solution (the 2 steps that worked for you did for me as well), but explain what the code.

Porta Capena

Thanks Liu, no problemo :) I am glad it works in your case too.
I hope this will be a good base of knowledge and save some struggle for others. I was looking for the answer quite a lot :P

アバター
Oscar Gonzalez
最善の回答

While I have already had the correct parameters in the configuration file.

1. Add the following flag in the odoo config file:

[options]
proxy_mode = True

2. Add this header in the nginx config (I added it in the 'location' block):

proxy_set_header X-Forwarded-Host $host;


my stripe logs and odoo logs return a 200 ok message.
it is only for the following two events webhooks that fail.
payment_intent.succeeded

payment_intent.amount_capturable_updated


The transaction does process well but for some reason the webhook keeps trying to resend it to odoo and i keep getting a 404 error again only for those two methods. After a week there are approx 1400 retries a day and it slows down the server considerably.


0
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Webhooks NameError: name 'request' is not defined 解決済
webhook
アバター
アバター
アバター
2
7月 24
3711
Is a webhook the best way to send data to a URL outside Odoo?
webhook
アバター
1
12月 22
4198
Webhooks - Create a lead 解決済
webhook webhooks
アバター
アバター
1
10月 24
4838
Error 500 Webhooks
saas webhook
アバター
アバター
アバター
2
8月 24
2304
How To send webhook data whenever I create, update, or delete records?
webhook API
アバター
アバター
1
9月 25
4061
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة 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(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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