Log the original IP address when Bitbucket Server is behind a load balancer or reverse proxy

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

症状

If Bitbucket Server is behind a load balancer or reverse proxy, you may see the load balancer's or reverse proxy's IP address in the atlassian-bitbucket-access.log instead of the IP address of the client making the request. 

ソリューション

For Bitbucket Server version 5 or later

In Bitbucket Server 5.0+ if the load balancer is sending over the x-forwarded-for header, this should be logged correctly in the access logs without any further configuration needed.

Whilst Bitbucket Server 5 will do this for you without additional configuration, if you need to customise these settings in Bitbucket Server 5, you can apply the following settings in $BITBUCKET_HOME/shared/bitbucket.properties:

server.tomcat.remote_ip_header=x-forwarded-for
server.tomcat.protocol_header=x-forwarded-proto
server.tomcat.internal_proxies=127\\.0\\.0\\.1
For Bitbucket Server 4

In order for this to work, the load balancer should send a header with the IP address of the original request, some load balancers use x-forwarded-for


Add a Valve element to your $BITBUCKET_HOME/shared/server.xml that is configured for the header that the load balancer is sending

<Engine name="Catalina" defaultHost="localhost">
          
    <Valve className="org.apache.catalina.valves.RemoteIpValve" 
        internalProxies="127\.0\.0\.1"  
        remoteIpHeader="x-forwarded-for" 
        remoteIpProxiesHeader="x-forwarded-by"
        protocolHeader="x-forwarded-proto" /> 



Last modified on Mar 27, 2019

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.