-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1da7f15
commit 9075a90
Showing
4 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM nginx:alpine | ||
|
||
WORKDIR /etc/nginx | ||
COPY ./nginx.conf ./conf.d/default.conf | ||
ENTRYPOINT [ "nginx" ] | ||
CMD [ "-g", "daemon off;" ] |
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,27 @@ | ||
# CORS NGINX Docker Proxy | ||
|
||
## What is this? | ||
|
||
This is a simple [NGINX](https://www.nginx.com/) docker server to | ||
append [CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) to HTTP responses from a GoPro camera. | ||
This proxy accepts input on port 80 and forwards it to `http:10.5.5.9:8080` | ||
|
||
## How do I use it? | ||
|
||
It is intended to be run using the `docker-compose.yml` here via: | ||
|
||
``` | ||
docker compose up | ||
``` | ||
|
||
Once running, an HTTP-connected-GoPro can be communicated with by replacing the default `10.5.5.9:8080` with | ||
`localhost:8082`. For example you can get the state via: | ||
|
||
``` | ||
curl http://localhost:8082/gopro/camera/state | ||
``` | ||
|
||
## Future work | ||
|
||
- [ ] Allow the camera IP and port to be set at run-time | ||
- [ ] Add camera HTTPS support |
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,7 @@ | ||
services: | ||
cors_proxy: | ||
container_name: cors_proxy | ||
build: | ||
context: . | ||
image: tcamise/gopro-cors-proxy | ||
ports: ['8082:80'] |
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,32 @@ | ||
upstream api { | ||
server 10.5.5.9:8080; | ||
} | ||
|
||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
add_header 'Access-Control-Allow-Origin' '*' always; | ||
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent, | ||
X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range' always; | ||
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always; | ||
|
||
location / { | ||
|
||
if ($request_method = 'OPTIONS') { | ||
add_header 'Access-Control-Max-Age' 1728000 always; | ||
add_header 'Access-Control-Allow-Origin' '*' always; | ||
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent, | ||
X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range' always; | ||
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always; | ||
return 204; | ||
} | ||
|
||
add_header 'Access-Control-Allow-Origin' '*' always; | ||
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent, | ||
X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range' always; | ||
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always; | ||
|
||
proxy_pass http://10.5.5.9:8080/; | ||
} | ||
} |