How to test if Confluence is resolving requests in a headless Linux server
目的
Sometimes it's necessary to test connectivity to Confluence hosted in a headless Linux environment. The methods described in this article should only be used if you have access to the headless server.
ソリューション
Using Telnet
- SSH to the headless server
- Find the listening port Confluence is listening on by opening the <Confluence Install Directory>/conf/server.xml file and finding the Connector port property. Note that you can have multiple connectors, however, the default one on newer versions of Confluence is 8090
- Also, note the Context path variable in the server.xml. In this example we will use Context path="/confluence"
Make sure Telnet is available on the server and run the following: telnet <localhost> <Port where Confluence is listening on> .
telnet localhost 8090
You will get connection details if connecting properly:
Trying ::1... Connected to localhost. Escape character is '^]'.
Run the following command and press enter 2 times:
GET </ContextPathNotedInPreviousSteps/> HTTP/1.1
HOST: localhostMake sure to add the "/" after the context path.
GET /confluence/ HTTP/1.1 HOST: localhost
If Tomcat is resolving requests properly, you should get a response from the login page in Confluence. Note the 302 found status and /confluence/login.action page location.
HTTP/1.1 302 Found Server: Apache-Coyote/1.1 X-Confluence-Request-Time: 1469203272054 Set-Cookie: JSESSIONID=6EBBD526BC2A2C4A252170285B4B80CD; Path=/confluence/; HttpOnly X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN Content-Security-Policy: frame-ancestors 'self' Location: /confluence/login.action?os_destination=%2Findex.action&permissionViolation=true Content-Type: text/html;charset=UTF-8 Content-Length: 0 Date: Fri, 22 Jul 2016 16:01:12 GMT
On the other hand, if you get a 400 Bad Request or 404 Not Found status, Tomcat is likely not resolving requests.
HTTP/1.1 400 Bad Request Server: Apache-Coyote/1.1 Transfer-Encoding: chunked Date: Fri, 22 Jul 2016 16:04:23 GMT Connection: close
Using cURL
- SSH to the headless server
- Find the listening port Confluence is listening on by opening the <Confluence Install Directory>/conf/server.xml file and finding the Connector port property. Note that you can have multiple connectors, however, the default one on newer versions of Confluence is 8090.
- Also, note the Context path variable in the server.xml. In this example we will use Context path="/confluence"
- Make sure you have cURL installed and are able to use it from the terminal or command prompt.
Run the following: curl -v <localhost>:<Port where Confluence is listening on>/<ContextPathNotedInPreviousSteps> .
curl -v localhost:8090/confluence
You will get connection details if connecting properly:
HTTP/1.1 302 Found < Date: Wed, 03 Aug 2016 15:27:03 GMT * Server Apache-Coyote/1.1 is not blacklisted < Server: Apache-Coyote/1.1 < Location: http://ProxiedHost/confluence/ < Content-Length: 0
- If you get a status of 302 Found, it means that Confluence is resolving requests on the specified URL.
On the other hand, if you get a 404 Not Found response, Confluence is likely not responding using the specified URL and port.
* Connected to localhost (::1) port 80 (#0) > GET /confluence HTTP/1.1 > User-Agent: curl/7.37.1 > Host: localhost > Accept: */* > < HTTP/1.1 404 Not Found < Date: Wed, 03 Aug 2016 15:36:53 GMT * Server Apache/2.4.9 (Unix) PHP/5.5.14 OpenSSL/0.9.8zc is not blacklisted < Server: Apache/2.4.9 (Unix) PHP/5.5.14 OpenSSL/0.9.8zc < Content-Length: 209 < Content-Type: text/html; charset=iso-8859-1
If you want to check what is returned when following the redirection run:
curl -vL localhost:8090/confluence
You will receive an output similar to the one below, which will show you the html code of the Confluence login page (or SSO login if configured):
* Connected to localhost (127.0.0.1) port 8090 (#0) > GET /c7137 HTTP/1.1 > Host: localhost:8090 > User-Agent: curl/7.74.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 302 < Location: /confluence/ < Transfer-Encoding: chunked < Date: Thu, 23 Feb 2023 11:07:37 GMT < * Ignoring the response-body { [5 bytes data] 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 * Connection #0 to host localhost left intact * Issue another request to this URL: 'http://localhost:8090/confluence/' * Found bundle for host localhost: 0xaaaacd893ef0 [serially] * Can not multiplex, even if we wanted to! * Re-using existing connection! (#0) with host localhost * Connected to localhost (127.0.0.1) port 27137 (#0) > GET /confluence/ HTTP/1.1 > Host: localhost:8090 > User-Agent: curl/7.74.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 < Cache-Control: no-store < Expires: Thu, 01 Jan 1970 00:00:00 GMT < X-Confluence-Request-Time: 1677150457485 < Set-Cookie: JSESSIONID=FB5CF728ED905E1638872DCF41286467; Path=/confluence; HttpOnly < X-XSS-Protection: 1; mode=block < X-Content-Type-Options: nosniff < X-Frame-Options: SAMEORIGIN < Content-Security-Policy: frame-ancestors 'self' < X-Accel-Buffering: no < Content-Type: text/html;charset=UTF-8 < Transfer-Encoding: chunked < Date: Thu, 23 Feb 2023 11:07:37 GMT < { [7717 bytes data] <!DOCTYPE html> <html> [...] </html> * Connection #0 to host localhost left intact