i have nginx which have sertificate signed trusted center. Here config of nginx
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name site.ru;
ssl_certificate $HOME/.site.crt;
ssl_certificate_key $HOME/.site.key;
if ($scheme != "https") {
return 301 https://localhost:8282$request_uri;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass http://localhost:8282/;
}
Behind this nginx, on 8282 port, listen golang server with some api. If i try to apply to the api from other network, not localhost(android web browser+internet from SIM for example) https://domain.name/myapi/?param1=value
, if this api doesn’t have internal call to api, i get corretly answer from this api. But if i try to call api whose have internal call to api in localhost, i get incorrect result, because apis can’t communicate between if it locate inside one network(localhost). Example api which get incorrect result and locate inside localhost
func Create_user(w http.ResponseWriter, r *http.Request) {
encode_data := Get_encoded_form_values(w, r)
decode_data := JSON_struct{}
tmplsrv.Decoding(encode_data, &decode_data)
params := url.Values{
"email": {r.FormValue("email")},
"password": {r.FormValue("password")},
}
//call other api which check existence user in database
check_user_answer := Requester("https://localhost/check_user/", w, r, encode_data, params)
answer := Answer{}
tmplsrv.Decoding(check_user_answer, &answer)
if answer.Answr == "NotFound" {
//Call other api for new token .
new_token_answer := Requester("https://localhost/create_token/", w, r, encode_data, params)
tmplsrv.Decoding(new_token_answer, &answer)
decode_data.JWT_token = answer.Answr
database.Inserting_user_in_db(tmplsrv.Encoding(decode_data))
w.WriteHeader(http.StatusCreated)
w.Write([]byte("created"))
}
if answer.Answr == "" {
// I always locate in this conditin because internal call apis unsuccsessful
w.Write([]byte("Unable to create user"))
} else {
w.Write([]byte("User exists"))
}
}
But if i disable nginx i can make internal call api by http://ip:port/uri?values
.
How can i make call api inside localhost with nginx? Thanks