Created
October 31, 2012 22:49
-
-
Save qbart/3990460 to your computer and use it in GitHub Desktop.
nginx current time from server in seconds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpClient httpClient = new DefaultHttpClient(); | |
HttpHead req = new HttpHead("http://xxxxx/_now"); | |
HttpResponse res = httpClient.execute(req); | |
Header header = res.getFirstHeader("x-now"); | |
String value = header.getValue(); | |
Long time = Long.parseLong(value) * 1000l; | |
Date now = new Date(time); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
location /_now { | |
add_header x-now $date_gmt; | |
access_log off; | |
return 204; | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment