ERROR USING NGINX AS REVERSE PROXY
June 16, 2016 02:24AM
Getting this error using NGINX as reverse proxy. Tried using / as a redirect but it gives error 404 not found. could try to use on any server
the code is attached below.
thanks

http {
include 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 logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;
upstream myapp1 {
server http://www.google.com;
}
server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

#location {
# root html;
# index index.html index.htm;

location /test {

proxy_pass http://myapp1;

}
Re: ERROR USING NGINX AS REVERSE PROXY
June 16, 2016 02:55AM
The location is passed on to the proxy, 'test' does not exist on google, looks like you need to rewrite location.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: ERROR USING NGINX AS REVERSE PROXY
June 16, 2016 04:24AM
Hi,
Thanks for the reply. I changed the location and NGINX worked but only on the local server. Every time i used it on an external host it gave me an error 404. The working code for the local host is posted below

upstream myapp1 {
server www.becpsn.com;

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

#location {
# root html;
# index index.html index.htm;

location /test {

proxy_pass http:/<local host>/example.png;

}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html
{
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Re: ERROR USING NGINX AS REVERSE PROXY
June 16, 2016 04:43AM
Enable debug and check the logfiles.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: ERROR USING NGINX AS REVERSE PROXY
June 20, 2016 12:35AM
i am not sure how to enable debug and check for logfiles? is there any step or method that you can tell me to include in my code?
thanks!
Re: ERROR USING NGINX AS REVERSE PROXY
June 20, 2016 04:17AM
https://easyengine.io/tutorials/nginx/debugging/

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: ERROR USING NGINX AS REVERSE PROXY
June 20, 2016 05:04AM
Still really stuck....
So in the code below now the page is loading but it gives the error server is taking to long to respond or server is not responding at all.

server {
listen 80;
server_name www.google.com;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;

location /test {

proxy_pass http://<local host>/testpage1;
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 113
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready