# The app we are proxying to upstream production-app { server localhost:8080; } # The internal oauth provider upstream internal-oauth { server localhost:1337; } server { listen 80; server_name private.example.com; root /apps; charset utf-8; # This will run for everything but subrequests access_by_lua_file "/etc/nginx/access.lua"; # Used in a subrequest location /_access_token { proxy_pass http://internal-oauth/oauth/access_token; } location /_user { proxy_pass http://internal-oauth/user; } location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_max_temp_file_size 0; if (!-f $request_filename) { proxy_pass http://production-app; break; } } }