Created
August 13, 2021 07:26
-
-
Save xtrsyz/b73fc137bd28933c6967afca26a89f99 to your computer and use it in GitHub Desktop.
upstream fivem multi ips
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
| #sudo apt-get install nginx-extras | |
| upstream dejavu { | |
| server 128.99.8.144:30120; | |
| } | |
| proxy_cache_path /nginx/cache/dejavu levels=1:2 keys_zone=dejavu:10m max_size=20g inactive=2h; | |
| server { | |
| listen 443 ssl http2; | |
| listen [::]:443 ssl http2; | |
| server_name dejavu.gigne.net; | |
| # this can also be a Cloudflare origin certificate if you're using CF | |
| ssl_certificate /etc/nginx/certificate.pem; | |
| ssl_certificate_key /etc/nginx/privkey.pem; | |
| location / { | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header X-Forwarded-Proto $scheme; | |
| # required to pass auth headers correctly | |
| proxy_pass_request_headers on; | |
| # required to not make deferrals close the connection instantly | |
| proxy_http_version 1.1; | |
| proxy_pass http://dejavu; | |
| } | |
| # if you do not wish to use the caching proxy, remove the below block | |
| location /files/ { | |
| proxy_pass http://dejavu$request_uri; | |
| add_header X-Cache-Status $upstream_cache_status; | |
| proxy_cache_lock on; | |
| proxy_cache dejavu; | |
| proxy_cache_valid 10m; | |
| proxy_cache_key $request_uri$is_args$args; | |
| proxy_cache_revalidate on; | |
| proxy_cache_min_uses 1; | |
| #proxy_read_timeout 3600; | |
| } | |
| location /client { | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header X-Forwarded-Proto $scheme; | |
| proxy_pass_request_headers on; | |
| proxy_http_version 1.1; | |
| if ($request_method = POST ) { | |
| set $upstream ''; | |
| access_by_lua ' | |
| ngx.req.read_body() | |
| local data = ngx.req.get_body_data() | |
| local match = ngx.re.match(ngx.var.request_body, "getEndpoints") | |
| if match then | |
| ngx.var.upstream = "127.0.0.1/getEndpoints" | |
| else | |
| ngx.var.upstream = "dejavu" | |
| end | |
| '; | |
| proxy_pass https://$upstream; | |
| } | |
| } | |
| location /getEndpoints { | |
| default_type application/json; | |
| content_by_lua_block { | |
| if math.random(2) == 2 then | |
| ngx.say('["54.139.205.126:30120"]'); | |
| else | |
| ngx.say('["147.179.19.213:30120"]'); | |
| end | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment