1
- ## Taytay:
2
1
## The below contents and nginx_3scale_access.lua are created by 3Scale by
3
2
## following the steps here:
4
3
## https://support.3scale.net/howtos/api-configuration/nginx-proxy
5
4
##
6
- ## (I've taken the generated .conf file and modified it to work on Heroku)
7
- ## You'll replace the contents below with the .conf file that 3Scale gives you
8
- ## Then, you'll make the same minor modifications I did. Just search for
9
- ## 'HEROKU CHANGE:'
10
- ## 3Scale already has some change markers called "NEED CHANGE"
11
- ## You can probably ignore them for the simplest tests
5
+ ## A few minor modifications are necessary to get the generated config
6
+ ## to work on Heroku. Search for 'HEROKU CHANGE:' in this file and make the same
7
+ ## changes to your nginx.conf file
8
+ ## Note that 3Scale puts their own change markers in the generated called
9
+ ## "NEED CHANGE", so you will see some of those below too.
12
10
13
11
## NEED CHANGE (defines the user of the nginx workers)
14
12
# user user group;
15
13
16
14
## THIS PARAMETERS BE SAFELY OVER RIDDEN BY YOUR DEFAULT NGINX CONF
17
15
worker_processes 2 ;
18
16
error_log logs/error.log warn ;
19
- # HEROKU CHANGE: We don't want it running as a daemon, but as a normal process
17
+
18
+ ## HEROKU CHANGE: Add this "daemon off" line to your file so that it runs as a
19
+ ## normal process rather than a daemon
20
20
daemon off ;
21
21
22
22
events {
@@ -36,20 +36,23 @@ http {
36
36
}
37
37
38
38
server {
39
- #HEROKU CHANGE: We have to have this placeholder port in here to work on Heroku
39
+ ## HEROKU CHANGE: Heroku assigns a different port every time, so use this
40
+ ## placeholder instead of hardcoding it:
40
41
listen ${{PORT}};
41
42
42
- ## HEROKU CHANGE: CHANGE YOUR SERVER NAME TO YOUR CUSTOM DOMAIN OR COMMENT IT OUT IF ONLY HAVE ONE
43
+ ## CHANGE YOUR SERVER_NAME TO YOUR CUSTOM DOMAIN OR COMMENT IT OUT IF ONLY HAVE ONE
43
44
#server_name api-proxy-3scale-heroku.herokuapp.com;
44
45
underscores_in_headers on;
45
46
46
47
location = /threescale_authrep {
47
48
internal ;
48
- ## HEROKU CHANGE: MAKE A HEROKU ENVIRONMENT VARIABLE CALLED 3SCALE_PROVIDER_KEY
49
- ## >heroku config:set 3SCALE_PROVIDER_KEY=1239832745abcde...
49
+ ## HEROKU CHANGE: (OPTIONAL)
50
50
## 3Scale normally hardcodes the provider_key here, but if you want to avoid
51
- ## checking that into source code, you can use Heroku environment variables
52
- set $provider_key "${{3SCALE_PROVIDER_KEY}}" ;
51
+ ## checking that into source code, you can create a Heroku config
52
+ ## environment variable called "3SCALE_PROVIDER_KEY" and uncomment the
53
+ ## following line.
54
+ #set $provider_key "${{3SCALE_PROVIDER_KEY}}";
55
+ set $provider_key "hardcoded_secret_3scale_providerkey" ;
53
56
54
57
proxy_pass http://threescale_backend/transactions/authrep.xml?provider_key=$provider_key &service_id=$service_id &$usage &$credentials ;
55
58
proxy_set_header Host su1.3scale.net;
59
62
internal ;
60
63
proxy_pass_request_headers off ;
61
64
##needs to be in both places, better not to have it on location / for potential security issues, req. are internal
62
- ## HEROKU CHANGE: MAKE A HEROKU ENVIRONMENT VARIABLE CALLED 3SCALE_PROVIDER_KEY
63
- ## >heroku config: set 3SCALE_PROVIDER_KEY=1239832745abcde...
64
- set $provider_key "${{3SCALE_PROVIDER_KEY}} " ;
65
+ ## HEROKU CHANGE: (OPTIONAL) (see note above)
66
+ #set $provider_key "${{ 3SCALE_PROVIDER_KEY}}";
67
+ set $provider_key "hardcoded_secret_3scale_providerkey " ;
65
68
66
69
67
70
content_by_lua '
@@ -89,15 +92,14 @@ http {
89
92
set $cached_key null;
90
93
set $credentials null;
91
94
set $usage null;
92
- ## HEROKU CHANGE: This will be your own service id as told by 3Scale
93
95
set $service_id 1234567890 ;
94
96
set $proxy_pass null;
95
97
set $secret_token null;
96
98
97
99
proxy_ignore_client_abort on ;
98
100
99
- ## You don't need to change this unless you put the lua file in a different spot
100
- ## CHANGE THE PATH TO POINT TO THE RIGHT FILE ON YOUR FILESYSTEM
101
+ ## HEROKU CHANGE: Make sure you rename the generated . lua file to
102
+ ## nginx_3scale_access.lua so that this line works:
101
103
access_by_lua_file nginx_3scale_access.lua;
102
104
103
105
proxy_pass $proxy_pass ;
0 commit comments