Last active
November 28, 2018 14:32
-
-
Save yogeek/ff0a652cc4c28125afe24e91c68f2b4c to your computer and use it in GitHub Desktop.
Proxy conf in nginx with resolver
This file contains hidden or 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
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 |
This file contains hidden or 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
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