No resolver defined to resolve myipp.com in nginx on google cloud - nginx

My puprose is to use nginx as a proxy for another application and I get an error above and I get 502 badgateway when I try to access my app.
My nginx configurations are shown below and I already unlinked the default nginx configurations but I still get the error below in /var/log/nginx/error.log.
Any clues ?
server{
listen 80 default_server ;
listen [::]:80 default_server;
server_name pivot.staging.ippen.space;
location / {
resolver 127.0.0.53
proxy_pass https://$server_name:443/;
}
}
and when i used 127.0.0.1 / 8.8.8.8 as a resolver I get the folowing error:
nginx: [emerg] host not found in resolver "proxy_pass" in /etc/nginx/sites-enabled/custom_server.conf:9
I use nginx as a VM instance on Google cloud and I have two firewall rules (allow http and allow ssh access); OS is ubuntu 16.04.

Related

Nginx Proxy Pass dont acceppts user & password

i need to proxy pass one URL from my internal network, that looks like this here:
http://<user><passwd><ipaddress>:<port>/cgi-bin/mjpg/video.cgi?channel=1&subtype=1
But this configuration always ends up in an error:
nginx: [emerg] invalid port in upstream "user:passwd#192.168.133.122:8080/cgi-bin/mjpg/video.cgi?channel=1&subtype=1" in /etc/nginx/sites-enabled/default:15
nginx: configuration file /etc/nginx/nginx.conf test failed
The only working way i get nginx to work is this one:
server {
listen 80;
root /var/www/html;
index index.php index.html index.htm;
location /video.cgi {
proxy_pass http://192.168.133.122:8080/cgi-bin/mjpg/video.cgi?channel=1&subtype=1;
}
}
But in this configuration the User and the Password are not included. Is there a way to get user&password also in the proxy_pass?
thanks
Franz

Nginx proxy conf for minecraft not working

Hi I am trying to get a nginx conf working with minecraft.
I created several subdomains (A-records) and I want to use only the subdomains (without port).
Therefore I installed nginx (stable release) on CentOS 7.
Added portforward in my router on 25565 to this VM (fixed IP) and added 25565 (tcp, permanent) to the firewall. Testing nginx with default ip (port 80) => Welcome to nginx....
Testing port 25565 (with minecraft) also works.
Left nginx.conf and default.conf intact (no changes) and added my minecraft.conf in /etc/nginx/conf.d/
Minecraft uses tcp protocol (I asume this is supported by nginx) and listens default to 25565 that's why I run my instances on 25566 and 25567
As far as I understood main directives like http(s), stream etc. should be declared in nginx.conf
It's not posible to declare a stream in the minecraft.conf (in ./conf.d/)
Also not possible to proxy_pass to the upstream (directive proxy_pass not allowed here)
(I can use location / { http://..} but that's not tcp)
What do I miss to make it work as I want to use a proxy (Network Solutions does not allow SRV records for subdomains)
my minecraft.conf:
upstream mcserver1 {
server 192.168.1.14:25566;
}
upstream mcserver2 {
server 192.168.1.14:25567;
}
server {
listen 25565;
server_name camelot.xyz.net;
access_log /var/log/nginx/mcs1.access;
error_log /var/log/nginx/mcs1.error;
proxy_pass mcserver1;
}
server {
listen 25565;
server_name cityworld.xyz.net;
access_log /var/log/nginx/mcs2.access;
error_log /var/log/nginx/mcs2.error;
proxy_pass mcserver2;
}
In the default error.log I find
2021/04/11 21:37:12 [notice] 5525#5525: signal process started
2021/04/11 21:37:12 [emerg] 2325#2325: bind() to 0.0.0.0:25565 failed (98: Address already in use)
2021/04/11 21:37:12 [emerg] 2325#2325: still could not bind()

Basic proxy_pass from nginx from one local ip to another local ip

I am a new user of nginx and I am following a video guide from Linode on youtube (How to Set Up an NGINX Reverse Proxy).
I have a working nginx and apache server both on port 80. I know that because when I type the ip address of both in firefox, it directs me to nginx/apache welcome page.
The youtube video configuration template is as follow (where the server_name is the linode ip) :
server {
listen 80;
listen [..]:80;
server_name 172.105.104.226;
location / {
proxy_pass http://localhost:3000/;
}
On my Proxmox machine, the nginx server is on a VM at 192.168.1.241 and the apache server on another VM at 192.168.1.243.
Looking at nginx documentation we find that this :
location /some/path/ {
proxy_pass http://www.example.com/link/;
}
should proxy all the traffic received on the nginx listening port and redirect it to the address specified by proxy pass.
With all these information, my configuration file is like this :
server {
listen 80;
listen [::]:80;
server_name 192.168.1.241;
location / {
proxy_pass http://192.168.1.243;
}
}
My understanding is that this configuration file should listen at the address 192.168.1.241 on port 80 (nginx server) and redirect it to the specified address 192.168.1.243 (apache server)/
If i understand correctly, Location / should take the request as is received on the nginx server and redirect it to the apache server.
However, when I enter 192.168.1.241 in my browser, it doesn't show the apache welcome message but shows the nginx welcome message. That means that the proxy isn't working.
My nginx understanding is extremely limited as I am just starting to learn, but to me it seems like this should work but doesn't.
Thank you for your help
It turns out that the configuration is correct.
The problem was that the webpage was cached. By forcing a full refresh, 192.168.1.241 redirected to 192.168.1.243 successfully.

nginx port binding issues

Of course the port is already in use! hence my desire to redirect it! - I don't understand how I'm suppose to be able to redirect an app on 8787 to the https version if I can't start nginx due to this bind error?
nginx: configuration file /etc/nginx/nginx.conf test is successful
nginx: [emerg] bind() to 0.0.0.0:8787 failed (98: Address already in use)
server block:
server {
listen 8787;
listen [::]:8787 ipv6only=on;
server_name www.example.* example.* 45.224.123.199;
# SSL
ssl_certificate /etc/nginx/ssl/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/sample.key;
port_in_redirect off;
return 302 https://example.com$request_uri;
}
Each application , in this case the upstream application and nginx, need their own unique ip and port binding pair. Generally, ONE application per IP can anybind.
You need to either:
choose a unique port for the proxy and upstream pairing (change nginx port, or change application port)
OR
chose a unique IP binding for your application.
Very often, a good practice is to application bind to the LAN ip instead of the public IP, to better isolate your application from the public internet.

Nginx unknown directive "proxy_pass"

I'm having a problem with nginx configuration.
When I set the configuration like this:
server {
server_name redmine;
listen 80;
location / {
proxy_pass http://172.16.0.70:33000;
}
}
I get this error nginx: [emerg] unknown directive "proxy_pass".
My nginx version is nginx/1.8.0.
Someone know what i'm missing or what i'm doing wrong? Thanks.
Seems that module ngx_http_proxy_module is not installed
Run nginx -V to view how nginx is configured. If it is configured with option --without-http_proxy_module than nginx doesn't have proxy module and should be recompiled.

Resources