Skip to content

Instantly share code, notes, and snippets.

@yogeek
Last active November 28, 2018 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yogeek/ff0a652cc4c28125afe24e91c68f2b4c to your computer and use it in GitHub Desktop.
Save yogeek/ff0a652cc4c28125afe24e91c68f2b4c to your computer and use it in GitHub Desktop.
Proxy conf in nginx with resolver
server {
listen 80;
server_name _;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~ /meteofrance/ {
resolver 8.8.8.8;
set $meteo "api.meteofrance.com";
rewrite ^\/meteofrance\/(.*) /$1 break;
proxy_pass http://$meteo;
}
}
# docker run --rm -p 80:80 -v $(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf -d nginx
# Test : http://localhost/forecast?token=demod2c&lat=43.39664000302594&lon=1.5246332795496096&lang=en
server {
listen 80;
server_name _;
return 301 $scheme://URL1$request_uri;
}
server {
listen 5000;
server_name _;
return 301 $scheme://URL2$request_uri;
}
# docker run --rm -p 80:80 -p 5000:5000 -v $(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf -d nginx
# Test : http://localhost
# Test : http://localhost:5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment