Mattermost, Inc.

Doing curl test for incoming webhook returns 403 error

Summary

Doing curl test for incoming webhook returns 403 error.

Steps to reproduce

0.Follow this guide https://docs.mattermost.com/developer/webhooks-incoming.html
1.Create incoming webhook
2.Run this command:

curl -i -X POST -H ‘Content-Type: application/json’ -d ‘{“text”: “Hello, this is some text\nThis is more text. :tada:”}’ http://172.28.64.51:8065/hooks/wdohzcuksjrgurb614gdk79zoc

Expected behavior

Should be successed…

Observed behavior

Return:

HTTP/1.1 403 Forbidden
Server: squid
Mime-Version: 1.0
Date: Thu, 05 Apr 2018 17:10:00 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 2062
X-Squid-Error: ERR_ACCESS_DENIED 0
Vary: Accept-Language
Content-Language: en
X-Cache: MISS from proxy-2_10
Via: 1.1 proxy-2_10:8010
Proxy-Connection: close

Web Page Cannot Be Displayed <!--
                    body {
                            font-family: Arial,Sans-serif;
                    }

                    li {
                            padding-top: 5px;
                    }

                    .messageBox {
                            BORDER-TOP: #9c9a9c 1px solid;
                            BORDER-LEFT: #9c9a9c 1px solid;
                            BORDER-RIGHT: #9c9a9c 1px solid;
                            BORDER-BOTTOM: #9c9a9c 1px solid;
                    }

                    .alertTitle
                    {
                            color: #676767;
                            FONT-SIZE: 12px;
                            font-weight: bold;
                    }

                    .alertText
                    {
                            color: #676767;
                            FONT-SIZE: 11px;
                            font-weight: normal;
                            padding-left: 15px;
                            padding-right: 15px;
                    }

            -->
            </style>
    </HEAD>
    <body>
            <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
                    <tr>
                            <td align="center" valign="center">
                                    <table>
                                            <tr>
                                                    <td>
                                                            <table border="0" class="messageBox">
                                                                    <tr>
                                                                            <td height="25">&nbsp;</td>
                                                                    </tr>
                                                                    <tr>
                                                                            <td align="center">
                                                                                    <table border="0" width="490">
                                                                                            <tr>
                                                                                                    <td class="alertTitle" align="center">
                                                                                                            <strong>Unable to display page</strong>
                                                                                                    </td>
                                                                                            </tr>
                                                                                            <tr class="spacerRow">
                                                                                                    <td></td>
                                                                                            </tr>
                                                                                            <tr>
                                                                                                    <td class="alertText" align="left">
                                                                                                            It has not been possible to display the page you requested for the following reason:
                                                                                                            <ul>
                                                                                                                    <li>Access Denied</li>
                                                                                                            </ul>
                                                                                                            Contact your system administrator if you continue to experience difficulties.
                                                                                                    </td>
                                                                                            </tr>
                                                                                    </table>
                                                                            </td>
                                                                    </tr>
                                                                    <tr>
                                                                            <td height="25">&nbsp;</td>
                                                                    </tr>
                                                            </table>
                                                    </td>
                                            </tr>
                                            <tr>
                                                    <td align="right"><asp:Label id="lblDateTime" runat="server" CssClass="AlertText" /></td>
                                            </tr>
                                    </table>
                            </td>
                    </tr>
            </table>
    </body>

Hi there,

It looks like you have a Squid proxy between you and the Mattermost server you’re trying to access that you’ll need to authenticate with before you can get to the server. Here’s a good resource on how to use curl to do this.

Thanks for your reply!
This error happens on localhost. Everything’s ok when I test from an other machine.
But, I still have no idea with:
Why squid? Why does squied need my auth? Acutally, I don’t even remember installing it. (Typing ‘squid’ in Terminal shows apt-get suggestion)

It seems that I have figured out what the problem is.
Just add a --noproxy parameter on curl command can fix the problem.

~$ curl –noproxy “*” -i -X POST --data-urlencode ‘payload={“text”: “Hello, this is some text\nThis is more text. :t
ada:”}’ http://172.28.64.51:8065/hooks/wdohzcuksjrgurb614gdk79zoc
HTTP/1.1 200 OK
Access-Control-Allow-Origin:
Content-Type: text/plain
X-Request-Id: 3nbkz4j63ff7upnuhfm6w6ppbh
X-Version-Id: 4.8.0.4.8.0.d39da9993707366832c9a9108a647ef3.false
Date: Sat, 07 Apr 2018 15:20:56 GMT
Content-Length: 2

But still have no idea about the blocking behavior of Squid. Can I think of that CURL uses Squid to process proxy ? :neutral_face:

Finally, adding no_proxy setting to my /etc/environment sloved the problem.