-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from OSC/monorepo
Monorepo for infrastructure
- Loading branch information
Showing
81 changed files
with
4,782 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1 |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Compiled Lua sources | ||
luac.out | ||
|
||
# luarocks build files | ||
*.src.rock | ||
*.zip | ||
*.tar.gz | ||
|
||
# Object files | ||
*.o | ||
*.os | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
*.def | ||
*.exp | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [0.5.0] - 2018-03-26 | ||
### Added | ||
- Add logging tag to logger to distinguish from other Lua log lines. | ||
|
||
### Changed | ||
- Changed log level for analytics and user mapping to debug to make logs less | ||
chatty. | ||
|
||
### Fixed | ||
- Fixed `req_handler` sometimes missing from logs. | ||
[#14](https://github.com/OSC/mod_ood_proxy/issues/14) | ||
|
||
## [0.4.0] - 2018-02-13 | ||
### Added | ||
- Added more verbose logging feature. | ||
[#12](https://github.com/OSC/mod_ood_proxy/issues/12) | ||
|
||
### Changed | ||
- Updated date in `LICENSE.txt`. | ||
|
||
## [0.3.1] - 2017-07-25 | ||
### Fixed | ||
- Fixed link to documentation in `README.md`. | ||
- Fixed version number in Lua code. | ||
|
||
## [0.3.0] - 2017-07-24 | ||
### Added | ||
- Add `OOD_USER_ENV` to specify CGI env var used for authenticated username | ||
|
||
### Changed | ||
- Replaced unnecessary 307 redirects with 302 redirects. | ||
- Ignore errors when stopping NGINX with a redirect URL. | ||
- Modified `CHANGELOG.md` format. | ||
|
||
### Removed | ||
- Removed the `/nginx/start` URL option. | ||
|
||
### Fixed | ||
- Fix for GA session blow up due to changing document referrer. | ||
[#11](https://github.com/OSC/mod_ood_proxy/issues/11) | ||
|
||
## [0.2.0] - 2017-01-30 | ||
### Removed | ||
- Remove support for client-side analytics (prefer server-side analytics). | ||
|
||
### Fixed | ||
- Fix query params not being passed with `/rnode`. | ||
|
||
## [0.1.0] - 2017-01-13 | ||
### Added | ||
- Parse backend node server info from Apache supplied env vars instead of | ||
determining it from within mod | ||
|
||
## [0.0.6] - 2016-11-10 | ||
### Changed | ||
- Strip off query params in doc referer arg sent to analytics server. | ||
- Allow redirects in analytics request. | ||
- Increase network timeout of analytics request to 5 seconds. | ||
|
||
## [0.0.5] - 2016-10-27 | ||
### Added | ||
- Added server side analytics feature. | ||
|
||
### Removed | ||
- Reverted the `sub-uri` option when staging a PUN. | ||
|
||
## [0.0.4] - 2016-10-11 | ||
### Fixed | ||
- Fixed `nginx_stage pun` call with included `sub_uri` option. | ||
|
||
## [0.0.3] - 2016-09-23 | ||
### Added | ||
- Added sequence diagram to `README.md`. | ||
|
||
### Removed | ||
- Removed user map caching and made mapping more verbose. | ||
|
||
## [0.0.2] - 2016-08-04 | ||
### Added | ||
- Add cookie to help invalidate cache. | ||
|
||
## [0.0.1] - 2016-06-03 | ||
### Added | ||
- Initial release! | ||
|
||
[Unreleased]: https://github.com/OSC/mod_ood_proxy/compare/v0.5.0...HEAD | ||
[0.5.0]: https://github.com/OSC/mod_ood_proxy/compare/v0.4.0...v0.5.0 | ||
[0.4.0]: https://github.com/OSC/mod_ood_proxy/compare/v0.3.1...v0.4.0 | ||
[0.3.1]: https://github.com/OSC/mod_ood_proxy/compare/v0.3.0...v0.3.1 | ||
[0.3.0]: https://github.com/OSC/mod_ood_proxy/compare/v0.2.0...v0.3.0 | ||
[0.2.0]: https://github.com/OSC/mod_ood_proxy/compare/v0.1.0...v0.2.0 | ||
[0.1.0]: https://github.com/OSC/mod_ood_proxy/compare/v0.0.6...v0.1.0 | ||
[0.0.6]: https://github.com/OSC/mod_ood_proxy/compare/v0.0.5...v0.0.6 | ||
[0.0.5]: https://github.com/OSC/mod_ood_proxy/compare/v0.0.4...v0.0.5 | ||
[0.0.4]: https://github.com/OSC/mod_ood_proxy/compare/v0.0.3...v0.0.4 | ||
[0.0.3]: https://github.com/OSC/mod_ood_proxy/compare/v0.0.2...v0.0.3 | ||
[0.0.2]: https://github.com/OSC/mod_ood_proxy/compare/v0.0.1...v0.0.2 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2016-2018 Jeremy Nicklas | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# mod_ood_proxy | ||
|
||
![GitHub Release](https://img.shields.io/github/release/osc/mod_ood_proxy.svg) | ||
[![GitHub License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT) | ||
|
||
An Apache HTTP Server module implementing the Open OnDemand proxy API. | ||
|
||
For more information please visit the [Documentation]. | ||
|
||
[Documentation]: https://osc.github.io/ood-documentation/master/infrastructure/mod-ood-proxy.html | ||
|
||
## Contributing | ||
|
||
1. Fork it ( https://github.com/OSC/mod_ood_proxy/fork ) | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create a new Pull Request |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Build options | ||
PREFIX ||= ENV['PREFIX'] || '/opt/ood/mod_ood_proxy' | ||
|
||
# | ||
# Tasks | ||
# | ||
|
||
task :default => :install | ||
|
||
directory PREFIX | ||
|
||
# Dynamically generate tasks for copying required files | ||
FileList['lib/**/*.lua'].each do |source| | ||
target = "#{PREFIX}/#{source}" | ||
file target => [source, PREFIX] do | ||
mkdir_p File.dirname(target) unless File.directory? File.dirname(target) | ||
cp source, target | ||
end | ||
task :required_files => target | ||
end | ||
|
||
desc <<-DESC | ||
Install mod_ood_proxy into PREFIX | ||
Default: PREFIX=/opt/ood/mod_ood_proxy | ||
DESC | ||
task :install => :required_files |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--[[ | ||
analytics_handler | ||
Hooks into the final logging stage to parse the response headers before | ||
phoning home with analytics (required by OOD proposal). | ||
--]] | ||
function analytics_handler(r) | ||
-- read in OOD specific settings defined in the Apache config | ||
local tracking_url = r.subprocess_env['OOD_ANALYTICS_TRACKING_URL'] | ||
local tracking_id = r.subprocess_env['OOD_ANALYTICS_TRACKING_ID'] | ||
|
||
-- read in variables set previously in the request by mod_ood_proxy | ||
local user = r.subprocess_env['MAPPED_USER'] -- set by the user mapping code | ||
local time_user_map = r.subprocess_env['OOD_TIME_USER_MAP'] -- set by the user mapping code | ||
local time_begin_proxy = r.subprocess_env['OOD_TIME_BEGIN_PROXY'] -- set by the proxy code | ||
|
||
-- only track HTML pages and authenticated users | ||
if (r.headers_out['Content-Type'] or ''):match('text/html') and user then | ||
local version = '1' | ||
local hit_type = 'pageview' | ||
|
||
-- user | ||
local client_id = user .. '@' .. r.server_name | ||
local user_id = user .. '@' .. r.server_name | ||
|
||
-- session | ||
local user_ip = r.useragent_ip | ||
local user_agent = r.headers_in['User-Agent'] or '' | ||
|
||
-- traffic sources | ||
local doc_referrer = (r.headers_in['Referer'] or ''):match('^([^?]*)') | ||
|
||
-- system info | ||
local doc_encoding = ((r.headers_out['Content-Type'] or ''):match('charset=([%w-]+)') or ''):lower() | ||
local user_language = ((r.headers_in['Accept-Language'] or ''):match('^([%w-]+)') or ''):lower() | ||
|
||
-- content information | ||
local doc_host = r.server_name | ||
local doc_path = r.uri | ||
|
||
-- extra computed properties | ||
local unique_id = r:sha1(user .. user_ip .. doc_host .. doc_path .. r:clock()) | ||
local time_proxy = time_begin_proxy and math.floor((r:clock() - time_begin_proxy)/1000.0) or 0 | ||
local time_user_map = time_user_map and math.floor(time_user_map) or 0 | ||
|
||
-- custom dimensions / metrics | ||
local cd1 = user -- Username (User) | ||
local cd2 = unique_id -- Session ID (Session) | ||
local cd3 = os.date('!%Y-%m-%dT%TZ') -- Timestamp (Hit) | ||
local cd4 = r.user -- Remote Username (Hit) | ||
local cd5 = r.method -- Request Method (Hit) | ||
local cd6 = tostring(r.status) -- Request Status (Hit) | ||
local cd7 = doc_referrer -- Document Referrer (Hit) | ||
local cm1 = tostring(time_proxy) -- Proxy Time (Hit/Integer) | ||
local cm2 = tostring(time_user_map) -- User Map Time (Hit/Integer) | ||
|
||
-- process analytics | ||
-- NB: Do not use the measurement protocol's document referrer as it can | ||
-- start a new session when it changes (so we use a custom dimension) | ||
local now = r:clock() | ||
local query = 'v=' .. r:escape(version) .. | ||
'&t=' .. r:escape(hit_type) .. | ||
'&tid=' .. r:escape(tracking_id) .. | ||
'&cid=' .. r:escape(client_id) .. | ||
'&uid=' .. r:escape(user_id) .. | ||
'&uip=' .. r:escape(user_ip) .. | ||
'&ua=' .. r:escape(user_agent) .. | ||
'&de=' .. r:escape(doc_encoding) .. | ||
'&ul=' .. r:escape(user_language) .. | ||
'&dh=' .. r:escape(doc_host) .. | ||
'&dp=' .. r:escape(doc_path) .. | ||
'&cd1=' .. r:escape(cd1) .. | ||
'&cd2=' .. r:escape(cd2) .. | ||
'&cd3=' .. r:escape(cd3) .. | ||
'&cd4=' .. r:escape(cd4) .. | ||
'&cd5=' .. r:escape(cd5) .. | ||
'&cd6=' .. r:escape(cd6) .. | ||
'&cd7=' .. r:escape(cd7) .. | ||
'&cm1=' .. r:escape(cm1) .. | ||
'&cm2=' .. r:escape(cm2) | ||
local handle = io.popen("wget --post-data='" .. query .. "' " .. tracking_url .. " -O /dev/null -T 5 -nv 2>&1") | ||
output = handle:read('*all'):match('^%s*(.-)%s*$') | ||
handle:close() | ||
r:debug("Analytics input: '" .. query .. "'") | ||
r:debug("Analytics output: '" .. r:escape_logitem(output) .. "' [" .. (r:clock() - now)/1000.0 .. " ms]") | ||
end | ||
|
||
return apache2.DECLINED | ||
end |
Oops, something went wrong.