GET to NGINX reverse proxy works but POST gives me a 502 Bad Gateway Response The 2019 Stack Overflow Developer Survey Results Are InHelp needed setting up nginx to serve static filesnginx+ uwsgi gives 502 Bad GatewayNginx reverse proxy + URL rewriteReverse proxy 502 bad gatewayNginx, reverse proxy to 2 different Joomla sitesNginx (+Varnish) adds port 8080 to url when accessing url without slashNginx Reverse Proxy 502 Bad Gatewayreverse proxy nginx bad gatewayUniversal HTTPS to HTTP reverse proxy using nginxSimplest nginx reverse proxy to another container on same host gives 502 Bad Gateway / connection refused

Deal with toxic manager when you can't quit

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Why not take a picture of a closer black hole?

Does HR tell a hiring manager about salary negotiations?

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

A word that means fill it to the required quantity

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Is an up-to-date browser secure on an out-of-date OS?

What information about me do stores get via my credit card?

Why isn't the circumferential light around the M87 black hole's event horizon symmetric?

Output the Arecibo Message

Ubuntu Server install with full GUI

Can you cast a spell on someone in the Ethereal Plane, if you are on the Material Plane and have the True Seeing spell active?

If a sorcerer casts the Banishment spell on a PC while in Avernus, does the PC return to their home plane?

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Why doesn't UInt have a toDouble()?

Can I have a signal generator on while it's not connected?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

Geography at the pixel level

Can withdrawing asylum be illegal?

Correct punctuation for showing a character's confusion

Keeping a retro style to sci-fi spaceships?

How can I define good in a religion that claims no moral authority?



GET to NGINX reverse proxy works but POST gives me a 502 Bad Gateway Response



The 2019 Stack Overflow Developer Survey Results Are InHelp needed setting up nginx to serve static filesnginx+ uwsgi gives 502 Bad GatewayNginx reverse proxy + URL rewriteReverse proxy 502 bad gatewayNginx, reverse proxy to 2 different Joomla sitesNginx (+Varnish) adds port 8080 to url when accessing url without slashNginx Reverse Proxy 502 Bad Gatewayreverse proxy nginx bad gatewayUniversal HTTPS to HTTP reverse proxy using nginxSimplest nginx reverse proxy to another container on same host gives 502 Bad Gateway / connection refused



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am using NGINX as a reverse proxy and just put up a new service written in Go.



The service has two endpoints



GET /tracking/ping

POST /tracking/customer


In NGINX, I am using the following to proxy the request



location /v1/location/ 
proxy_pass http://path-to-tracking-service:8181/;



When curl the two endpoints such as the following, I get different results.



The GET /tracking/ping endpoint



curl -X GET https://example.com/v1/location/tracking/ping
"Pong!"


The 'POST /tracking/customer` endpoint



curl -H "Content-Type: application/json" -d '"userId":"1234"' https://example.com/v1/location/tracking/customer
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.9.12</center>
</body>




Not sure why this would happen. I am proxying other services I have and POST requests work perfectly fine.



Here is the nginx.conf



user nginx;
worker_processes 1;



error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events
worker_connections 1024;


http
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

#gzip on;

#include /etc/nginx/conf.d/*.conf;

#server
#include /etc/nginx/sites-enabled/*;
#

server
listen 80;
server_name *.example.com;
#return 301 https://$host$request_uri;
include /etc/nginx/sites-enabled/*;


server


#listen 80;
listen 443 ssl;
server_name *.example.com;

ssl_certificate /etc/ssl/example.crt;
ssl_certificate_key /etc/ssl/example.key;

#ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;

include /etc/nginx/sites-enabled/*;




I have separate files that are being linked to /sites-enabled that include my proxy_params declarations.



Two of them are the following



location /v1/location/ 
proxy_pass http://example.com:8181/;


location /v1/
proxy_pass http://example.com:8282/;



I could see their maybe being an issue with it getting confused by the /v1 on both the proxies, but it works for the GET endpoint.



EDIT



Some people have brought up the point that it may be panicking so I checked the docker logs for the go container and got the following



location-tracking-staging-1 | 2016-03-14T02:35:33.580963673Z 2016/03/14 02:35:33 http: panic serving 10.7.1.5:35613: no reachable servers
location-tracking-staging-1 | 2016-03-14T02:35:33.581005488Z goroutine 97 [running]:
location-tracking-staging-1 | 2016-03-14T02:35:33.581012905Z net/http.(*conn).serve.func1(0xc820057b00)
location-tracking-staging-1 | 2016-03-14T02:35:33.581017348Z /usr/local/go/src/net/http/server.go:1389 +0xc1
location-tracking-staging-1 | 2016-03-14T02:35:33.581030498Z panic(0x81e620, 0xc82013c5e0)
location-tracking-staging-1 | 2016-03-14T02:35:33.581034545Z /usr/local/go/src/runtime/panic.go:426 +0x4e9
location-tracking-staging-1 | 2016-03-14T02:35:33.581038792Z main.RepoCreateVendorLocation(0xc82011ecb8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
location-tracking-staging-1 | 2016-03-14T02:35:33.581042502Z /go/src/location-tracking/repo.go:19 +0x178
location-tracking-staging-1 | 2016-03-14T02:35:33.581047145Z main.VendorLocationCreate(0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581050747Z /go/src/location-tracking/handlers.go:63 +0x47b
location-tracking-staging-1 | 2016-03-14T02:35:33.581054911Z net/http.HandlerFunc.ServeHTTP(0x9965b0, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581058786Z /usr/local/go/src/net/http/server.go:1618 +0x3a
location-tracking-staging-1 | 2016-03-14T02:35:33.581062770Z github.com/gorilla/mux.(*Router).ServeHTTP(0xc820010640, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581066604Z /go/src/github.com/gorilla/mux/mux.go:103 +0x270
location-tracking-staging-1 | 2016-03-14T02:35:33.581070176Z net/http.serverHandler.ServeHTTP(0xc820056300, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581073992Z /usr/local/go/src/net/http/server.go:2081 +0x19e
location-tracking-staging-1 | 2016-03-14T02:35:33.581077629Z net/http.(*conn).serve(0xc820057b00)
location-tracking-staging-1 | 2016-03-14T02:35:33.581081221Z /usr/local/go/src/net/http/server.go:1472 +0xf2e
location-tracking-staging-1 | 2016-03-14T02:35:33.581084811Z created by net/http.(*Server).Serve
location-tracking-staging-1 | 2016-03-14T02:35:33.581088336Z /usr/local/go/src/net/http/server.go:2137 +0x44e









share|improve this question
























  • Please post your nginx config, especially the relevant location parts.

    – Tim
    Mar 13 '16 at 21:48











  • @Tim I have updated my post with nginx.conf as well as included the proxies defined under /sites-enabled

    – TheJediCowboy
    Mar 13 '16 at 22:22











  • Did your program panic?

    – Michael Hampton
    Mar 13 '16 at 22:35











  • @MichaelHampton not sure what you mean? As in a Go panic? (I am still very new to Go...)

    – TheJediCowboy
    Mar 13 '16 at 22:46






  • 2





    Looks like a panic to me. The big clue is that it tells you "panic"! Time to debug your code.

    – Michael Hampton
    Mar 14 '16 at 2:45

















1















I am using NGINX as a reverse proxy and just put up a new service written in Go.



The service has two endpoints



GET /tracking/ping

POST /tracking/customer


In NGINX, I am using the following to proxy the request



location /v1/location/ 
proxy_pass http://path-to-tracking-service:8181/;



When curl the two endpoints such as the following, I get different results.



The GET /tracking/ping endpoint



curl -X GET https://example.com/v1/location/tracking/ping
"Pong!"


The 'POST /tracking/customer` endpoint



curl -H "Content-Type: application/json" -d '"userId":"1234"' https://example.com/v1/location/tracking/customer
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.9.12</center>
</body>




Not sure why this would happen. I am proxying other services I have and POST requests work perfectly fine.



Here is the nginx.conf



user nginx;
worker_processes 1;



error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events
worker_connections 1024;


http
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

#gzip on;

#include /etc/nginx/conf.d/*.conf;

#server
#include /etc/nginx/sites-enabled/*;
#

server
listen 80;
server_name *.example.com;
#return 301 https://$host$request_uri;
include /etc/nginx/sites-enabled/*;


server


#listen 80;
listen 443 ssl;
server_name *.example.com;

ssl_certificate /etc/ssl/example.crt;
ssl_certificate_key /etc/ssl/example.key;

#ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;

include /etc/nginx/sites-enabled/*;




I have separate files that are being linked to /sites-enabled that include my proxy_params declarations.



Two of them are the following



location /v1/location/ 
proxy_pass http://example.com:8181/;


location /v1/
proxy_pass http://example.com:8282/;



I could see their maybe being an issue with it getting confused by the /v1 on both the proxies, but it works for the GET endpoint.



EDIT



Some people have brought up the point that it may be panicking so I checked the docker logs for the go container and got the following



location-tracking-staging-1 | 2016-03-14T02:35:33.580963673Z 2016/03/14 02:35:33 http: panic serving 10.7.1.5:35613: no reachable servers
location-tracking-staging-1 | 2016-03-14T02:35:33.581005488Z goroutine 97 [running]:
location-tracking-staging-1 | 2016-03-14T02:35:33.581012905Z net/http.(*conn).serve.func1(0xc820057b00)
location-tracking-staging-1 | 2016-03-14T02:35:33.581017348Z /usr/local/go/src/net/http/server.go:1389 +0xc1
location-tracking-staging-1 | 2016-03-14T02:35:33.581030498Z panic(0x81e620, 0xc82013c5e0)
location-tracking-staging-1 | 2016-03-14T02:35:33.581034545Z /usr/local/go/src/runtime/panic.go:426 +0x4e9
location-tracking-staging-1 | 2016-03-14T02:35:33.581038792Z main.RepoCreateVendorLocation(0xc82011ecb8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
location-tracking-staging-1 | 2016-03-14T02:35:33.581042502Z /go/src/location-tracking/repo.go:19 +0x178
location-tracking-staging-1 | 2016-03-14T02:35:33.581047145Z main.VendorLocationCreate(0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581050747Z /go/src/location-tracking/handlers.go:63 +0x47b
location-tracking-staging-1 | 2016-03-14T02:35:33.581054911Z net/http.HandlerFunc.ServeHTTP(0x9965b0, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581058786Z /usr/local/go/src/net/http/server.go:1618 +0x3a
location-tracking-staging-1 | 2016-03-14T02:35:33.581062770Z github.com/gorilla/mux.(*Router).ServeHTTP(0xc820010640, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581066604Z /go/src/github.com/gorilla/mux/mux.go:103 +0x270
location-tracking-staging-1 | 2016-03-14T02:35:33.581070176Z net/http.serverHandler.ServeHTTP(0xc820056300, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581073992Z /usr/local/go/src/net/http/server.go:2081 +0x19e
location-tracking-staging-1 | 2016-03-14T02:35:33.581077629Z net/http.(*conn).serve(0xc820057b00)
location-tracking-staging-1 | 2016-03-14T02:35:33.581081221Z /usr/local/go/src/net/http/server.go:1472 +0xf2e
location-tracking-staging-1 | 2016-03-14T02:35:33.581084811Z created by net/http.(*Server).Serve
location-tracking-staging-1 | 2016-03-14T02:35:33.581088336Z /usr/local/go/src/net/http/server.go:2137 +0x44e









share|improve this question
























  • Please post your nginx config, especially the relevant location parts.

    – Tim
    Mar 13 '16 at 21:48











  • @Tim I have updated my post with nginx.conf as well as included the proxies defined under /sites-enabled

    – TheJediCowboy
    Mar 13 '16 at 22:22











  • Did your program panic?

    – Michael Hampton
    Mar 13 '16 at 22:35











  • @MichaelHampton not sure what you mean? As in a Go panic? (I am still very new to Go...)

    – TheJediCowboy
    Mar 13 '16 at 22:46






  • 2





    Looks like a panic to me. The big clue is that it tells you "panic"! Time to debug your code.

    – Michael Hampton
    Mar 14 '16 at 2:45













1












1








1








I am using NGINX as a reverse proxy and just put up a new service written in Go.



The service has two endpoints



GET /tracking/ping

POST /tracking/customer


In NGINX, I am using the following to proxy the request



location /v1/location/ 
proxy_pass http://path-to-tracking-service:8181/;



When curl the two endpoints such as the following, I get different results.



The GET /tracking/ping endpoint



curl -X GET https://example.com/v1/location/tracking/ping
"Pong!"


The 'POST /tracking/customer` endpoint



curl -H "Content-Type: application/json" -d '"userId":"1234"' https://example.com/v1/location/tracking/customer
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.9.12</center>
</body>




Not sure why this would happen. I am proxying other services I have and POST requests work perfectly fine.



Here is the nginx.conf



user nginx;
worker_processes 1;



error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events
worker_connections 1024;


http
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

#gzip on;

#include /etc/nginx/conf.d/*.conf;

#server
#include /etc/nginx/sites-enabled/*;
#

server
listen 80;
server_name *.example.com;
#return 301 https://$host$request_uri;
include /etc/nginx/sites-enabled/*;


server


#listen 80;
listen 443 ssl;
server_name *.example.com;

ssl_certificate /etc/ssl/example.crt;
ssl_certificate_key /etc/ssl/example.key;

#ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;

include /etc/nginx/sites-enabled/*;




I have separate files that are being linked to /sites-enabled that include my proxy_params declarations.



Two of them are the following



location /v1/location/ 
proxy_pass http://example.com:8181/;


location /v1/
proxy_pass http://example.com:8282/;



I could see their maybe being an issue with it getting confused by the /v1 on both the proxies, but it works for the GET endpoint.



EDIT



Some people have brought up the point that it may be panicking so I checked the docker logs for the go container and got the following



location-tracking-staging-1 | 2016-03-14T02:35:33.580963673Z 2016/03/14 02:35:33 http: panic serving 10.7.1.5:35613: no reachable servers
location-tracking-staging-1 | 2016-03-14T02:35:33.581005488Z goroutine 97 [running]:
location-tracking-staging-1 | 2016-03-14T02:35:33.581012905Z net/http.(*conn).serve.func1(0xc820057b00)
location-tracking-staging-1 | 2016-03-14T02:35:33.581017348Z /usr/local/go/src/net/http/server.go:1389 +0xc1
location-tracking-staging-1 | 2016-03-14T02:35:33.581030498Z panic(0x81e620, 0xc82013c5e0)
location-tracking-staging-1 | 2016-03-14T02:35:33.581034545Z /usr/local/go/src/runtime/panic.go:426 +0x4e9
location-tracking-staging-1 | 2016-03-14T02:35:33.581038792Z main.RepoCreateVendorLocation(0xc82011ecb8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
location-tracking-staging-1 | 2016-03-14T02:35:33.581042502Z /go/src/location-tracking/repo.go:19 +0x178
location-tracking-staging-1 | 2016-03-14T02:35:33.581047145Z main.VendorLocationCreate(0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581050747Z /go/src/location-tracking/handlers.go:63 +0x47b
location-tracking-staging-1 | 2016-03-14T02:35:33.581054911Z net/http.HandlerFunc.ServeHTTP(0x9965b0, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581058786Z /usr/local/go/src/net/http/server.go:1618 +0x3a
location-tracking-staging-1 | 2016-03-14T02:35:33.581062770Z github.com/gorilla/mux.(*Router).ServeHTTP(0xc820010640, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581066604Z /go/src/github.com/gorilla/mux/mux.go:103 +0x270
location-tracking-staging-1 | 2016-03-14T02:35:33.581070176Z net/http.serverHandler.ServeHTTP(0xc820056300, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581073992Z /usr/local/go/src/net/http/server.go:2081 +0x19e
location-tracking-staging-1 | 2016-03-14T02:35:33.581077629Z net/http.(*conn).serve(0xc820057b00)
location-tracking-staging-1 | 2016-03-14T02:35:33.581081221Z /usr/local/go/src/net/http/server.go:1472 +0xf2e
location-tracking-staging-1 | 2016-03-14T02:35:33.581084811Z created by net/http.(*Server).Serve
location-tracking-staging-1 | 2016-03-14T02:35:33.581088336Z /usr/local/go/src/net/http/server.go:2137 +0x44e









share|improve this question
















I am using NGINX as a reverse proxy and just put up a new service written in Go.



The service has two endpoints



GET /tracking/ping

POST /tracking/customer


In NGINX, I am using the following to proxy the request



location /v1/location/ 
proxy_pass http://path-to-tracking-service:8181/;



When curl the two endpoints such as the following, I get different results.



The GET /tracking/ping endpoint



curl -X GET https://example.com/v1/location/tracking/ping
"Pong!"


The 'POST /tracking/customer` endpoint



curl -H "Content-Type: application/json" -d '"userId":"1234"' https://example.com/v1/location/tracking/customer
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.9.12</center>
</body>




Not sure why this would happen. I am proxying other services I have and POST requests work perfectly fine.



Here is the nginx.conf



user nginx;
worker_processes 1;



error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events
worker_connections 1024;


http
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

#gzip on;

#include /etc/nginx/conf.d/*.conf;

#server
#include /etc/nginx/sites-enabled/*;
#

server
listen 80;
server_name *.example.com;
#return 301 https://$host$request_uri;
include /etc/nginx/sites-enabled/*;


server


#listen 80;
listen 443 ssl;
server_name *.example.com;

ssl_certificate /etc/ssl/example.crt;
ssl_certificate_key /etc/ssl/example.key;

#ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;

include /etc/nginx/sites-enabled/*;




I have separate files that are being linked to /sites-enabled that include my proxy_params declarations.



Two of them are the following



location /v1/location/ 
proxy_pass http://example.com:8181/;


location /v1/
proxy_pass http://example.com:8282/;



I could see their maybe being an issue with it getting confused by the /v1 on both the proxies, but it works for the GET endpoint.



EDIT



Some people have brought up the point that it may be panicking so I checked the docker logs for the go container and got the following



location-tracking-staging-1 | 2016-03-14T02:35:33.580963673Z 2016/03/14 02:35:33 http: panic serving 10.7.1.5:35613: no reachable servers
location-tracking-staging-1 | 2016-03-14T02:35:33.581005488Z goroutine 97 [running]:
location-tracking-staging-1 | 2016-03-14T02:35:33.581012905Z net/http.(*conn).serve.func1(0xc820057b00)
location-tracking-staging-1 | 2016-03-14T02:35:33.581017348Z /usr/local/go/src/net/http/server.go:1389 +0xc1
location-tracking-staging-1 | 2016-03-14T02:35:33.581030498Z panic(0x81e620, 0xc82013c5e0)
location-tracking-staging-1 | 2016-03-14T02:35:33.581034545Z /usr/local/go/src/runtime/panic.go:426 +0x4e9
location-tracking-staging-1 | 2016-03-14T02:35:33.581038792Z main.RepoCreateVendorLocation(0xc82011ecb8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
location-tracking-staging-1 | 2016-03-14T02:35:33.581042502Z /go/src/location-tracking/repo.go:19 +0x178
location-tracking-staging-1 | 2016-03-14T02:35:33.581047145Z main.VendorLocationCreate(0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581050747Z /go/src/location-tracking/handlers.go:63 +0x47b
location-tracking-staging-1 | 2016-03-14T02:35:33.581054911Z net/http.HandlerFunc.ServeHTTP(0x9965b0, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581058786Z /usr/local/go/src/net/http/server.go:1618 +0x3a
location-tracking-staging-1 | 2016-03-14T02:35:33.581062770Z github.com/gorilla/mux.(*Router).ServeHTTP(0xc820010640, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581066604Z /go/src/github.com/gorilla/mux/mux.go:103 +0x270
location-tracking-staging-1 | 2016-03-14T02:35:33.581070176Z net/http.serverHandler.ServeHTTP(0xc820056300, 0x7f8a4366d978, 0xc8200c2ea0, 0xc820119260)
location-tracking-staging-1 | 2016-03-14T02:35:33.581073992Z /usr/local/go/src/net/http/server.go:2081 +0x19e
location-tracking-staging-1 | 2016-03-14T02:35:33.581077629Z net/http.(*conn).serve(0xc820057b00)
location-tracking-staging-1 | 2016-03-14T02:35:33.581081221Z /usr/local/go/src/net/http/server.go:1472 +0xf2e
location-tracking-staging-1 | 2016-03-14T02:35:33.581084811Z created by net/http.(*Server).Serve
location-tracking-staging-1 | 2016-03-14T02:35:33.581088336Z /usr/local/go/src/net/http/server.go:2137 +0x44e






nginx reverse-proxy curl






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 14 '16 at 2:38







TheJediCowboy

















asked Mar 13 '16 at 21:23









TheJediCowboyTheJediCowboy

2782412




2782412












  • Please post your nginx config, especially the relevant location parts.

    – Tim
    Mar 13 '16 at 21:48











  • @Tim I have updated my post with nginx.conf as well as included the proxies defined under /sites-enabled

    – TheJediCowboy
    Mar 13 '16 at 22:22











  • Did your program panic?

    – Michael Hampton
    Mar 13 '16 at 22:35











  • @MichaelHampton not sure what you mean? As in a Go panic? (I am still very new to Go...)

    – TheJediCowboy
    Mar 13 '16 at 22:46






  • 2





    Looks like a panic to me. The big clue is that it tells you "panic"! Time to debug your code.

    – Michael Hampton
    Mar 14 '16 at 2:45

















  • Please post your nginx config, especially the relevant location parts.

    – Tim
    Mar 13 '16 at 21:48











  • @Tim I have updated my post with nginx.conf as well as included the proxies defined under /sites-enabled

    – TheJediCowboy
    Mar 13 '16 at 22:22











  • Did your program panic?

    – Michael Hampton
    Mar 13 '16 at 22:35











  • @MichaelHampton not sure what you mean? As in a Go panic? (I am still very new to Go...)

    – TheJediCowboy
    Mar 13 '16 at 22:46






  • 2





    Looks like a panic to me. The big clue is that it tells you "panic"! Time to debug your code.

    – Michael Hampton
    Mar 14 '16 at 2:45
















Please post your nginx config, especially the relevant location parts.

– Tim
Mar 13 '16 at 21:48





Please post your nginx config, especially the relevant location parts.

– Tim
Mar 13 '16 at 21:48













@Tim I have updated my post with nginx.conf as well as included the proxies defined under /sites-enabled

– TheJediCowboy
Mar 13 '16 at 22:22





@Tim I have updated my post with nginx.conf as well as included the proxies defined under /sites-enabled

– TheJediCowboy
Mar 13 '16 at 22:22













Did your program panic?

– Michael Hampton
Mar 13 '16 at 22:35





Did your program panic?

– Michael Hampton
Mar 13 '16 at 22:35













@MichaelHampton not sure what you mean? As in a Go panic? (I am still very new to Go...)

– TheJediCowboy
Mar 13 '16 at 22:46





@MichaelHampton not sure what you mean? As in a Go panic? (I am still very new to Go...)

– TheJediCowboy
Mar 13 '16 at 22:46




2




2





Looks like a panic to me. The big clue is that it tells you "panic"! Time to debug your code.

– Michael Hampton
Mar 14 '16 at 2:45





Looks like a panic to me. The big clue is that it tells you "panic"! Time to debug your code.

– Michael Hampton
Mar 14 '16 at 2:45










1 Answer
1






active

oldest

votes


















0














Plan



  • Run https://gist.github.com/bradmontgomery/2219997 as separate process on port 5000


  • proxy_pass python http server to https using POST requests


Problem with "502 Bad Gateway" giving config



  • cat /etc/nginx/sites-enabled/example.local


server 
location /random
proxy_pass http://127.0.0.1:5000;





root@sf:/var/www# curl -d "foo=bar&bin=baz" http://localhost:5000



<html><body><h1>hi!</h1></body></html>


root@sf:/var/www# curl -d "foo=bar&bin=baz" https://example.local/random



<html>
<head><title>502 Bad Gateway</title></head>
....


Solution



  • After deep research I found this article and I tried it out:
    http://invalidlogic.com/2011/04/12/serving-static-content-via-post-from-nginx/

nginx config after changes:



server 
...
error_page 502 =200 @502;

location /random
proxy_pass http://127.0.0.1:5000;



location @502
root /var/www/sf_random;
proxy_method GET;
proxy_pass http://127.0.0.1:5000;





  • config syntax validation



    nginx -t




  • after successful validation



    service nginx restart



And I got it working :)






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "2"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f763499%2fget-to-nginx-reverse-proxy-works-but-post-gives-me-a-502-bad-gateway-response%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Plan



    • Run https://gist.github.com/bradmontgomery/2219997 as separate process on port 5000


    • proxy_pass python http server to https using POST requests


    Problem with "502 Bad Gateway" giving config



    • cat /etc/nginx/sites-enabled/example.local


    server 
    location /random
    proxy_pass http://127.0.0.1:5000;





    root@sf:/var/www# curl -d "foo=bar&bin=baz" http://localhost:5000



    <html><body><h1>hi!</h1></body></html>


    root@sf:/var/www# curl -d "foo=bar&bin=baz" https://example.local/random



    <html>
    <head><title>502 Bad Gateway</title></head>
    ....


    Solution



    • After deep research I found this article and I tried it out:
      http://invalidlogic.com/2011/04/12/serving-static-content-via-post-from-nginx/

    nginx config after changes:



    server 
    ...
    error_page 502 =200 @502;

    location /random
    proxy_pass http://127.0.0.1:5000;



    location @502
    root /var/www/sf_random;
    proxy_method GET;
    proxy_pass http://127.0.0.1:5000;





    • config syntax validation



      nginx -t




    • after successful validation



      service nginx restart



    And I got it working :)






    share|improve this answer



























      0














      Plan



      • Run https://gist.github.com/bradmontgomery/2219997 as separate process on port 5000


      • proxy_pass python http server to https using POST requests


      Problem with "502 Bad Gateway" giving config



      • cat /etc/nginx/sites-enabled/example.local


      server 
      location /random
      proxy_pass http://127.0.0.1:5000;





      root@sf:/var/www# curl -d "foo=bar&bin=baz" http://localhost:5000



      <html><body><h1>hi!</h1></body></html>


      root@sf:/var/www# curl -d "foo=bar&bin=baz" https://example.local/random



      <html>
      <head><title>502 Bad Gateway</title></head>
      ....


      Solution



      • After deep research I found this article and I tried it out:
        http://invalidlogic.com/2011/04/12/serving-static-content-via-post-from-nginx/

      nginx config after changes:



      server 
      ...
      error_page 502 =200 @502;

      location /random
      proxy_pass http://127.0.0.1:5000;



      location @502
      root /var/www/sf_random;
      proxy_method GET;
      proxy_pass http://127.0.0.1:5000;





      • config syntax validation



        nginx -t




      • after successful validation



        service nginx restart



      And I got it working :)






      share|improve this answer

























        0












        0








        0







        Plan



        • Run https://gist.github.com/bradmontgomery/2219997 as separate process on port 5000


        • proxy_pass python http server to https using POST requests


        Problem with "502 Bad Gateway" giving config



        • cat /etc/nginx/sites-enabled/example.local


        server 
        location /random
        proxy_pass http://127.0.0.1:5000;





        root@sf:/var/www# curl -d "foo=bar&bin=baz" http://localhost:5000



        <html><body><h1>hi!</h1></body></html>


        root@sf:/var/www# curl -d "foo=bar&bin=baz" https://example.local/random



        <html>
        <head><title>502 Bad Gateway</title></head>
        ....


        Solution



        • After deep research I found this article and I tried it out:
          http://invalidlogic.com/2011/04/12/serving-static-content-via-post-from-nginx/

        nginx config after changes:



        server 
        ...
        error_page 502 =200 @502;

        location /random
        proxy_pass http://127.0.0.1:5000;



        location @502
        root /var/www/sf_random;
        proxy_method GET;
        proxy_pass http://127.0.0.1:5000;





        • config syntax validation



          nginx -t




        • after successful validation



          service nginx restart



        And I got it working :)






        share|improve this answer













        Plan



        • Run https://gist.github.com/bradmontgomery/2219997 as separate process on port 5000


        • proxy_pass python http server to https using POST requests


        Problem with "502 Bad Gateway" giving config



        • cat /etc/nginx/sites-enabled/example.local


        server 
        location /random
        proxy_pass http://127.0.0.1:5000;





        root@sf:/var/www# curl -d "foo=bar&bin=baz" http://localhost:5000



        <html><body><h1>hi!</h1></body></html>


        root@sf:/var/www# curl -d "foo=bar&bin=baz" https://example.local/random



        <html>
        <head><title>502 Bad Gateway</title></head>
        ....


        Solution



        • After deep research I found this article and I tried it out:
          http://invalidlogic.com/2011/04/12/serving-static-content-via-post-from-nginx/

        nginx config after changes:



        server 
        ...
        error_page 502 =200 @502;

        location /random
        proxy_pass http://127.0.0.1:5000;



        location @502
        root /var/www/sf_random;
        proxy_method GET;
        proxy_pass http://127.0.0.1:5000;





        • config syntax validation



          nginx -t




        • after successful validation



          service nginx restart



        And I got it working :)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 21 '18 at 21:57









        ErkkoErkko

        1




        1



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Server Fault!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f763499%2fget-to-nginx-reverse-proxy-works-but-post-gives-me-a-502-bad-gateway-response%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

            Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

            Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020