Nginx on front of node.js and apache - apache

I have nginx running on port 80 with a proxy pass for multiple node.js instances.
I'd like to also use nginx on the same port, to proxy for an apache instance running on another port, say 8888.
Here's the basics of my nginx.conf
upstream localhost {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost;
}
location /admin/ {
proxy_pass 127.0.0.1:8888;
}
}
The two upstream's are node.js instances. But the /admin/ is for the site on apache, however it doens't work.
Is there another way to do this?
Thank you!

location /admin/ {
proxy_pass http://127.0.0.1:8888;
}
http://nginx.org/r/proxy_pass

Related

NGINX reverse proxy two different server as backend

I am just new to NGINX.
I set up NGINX as a reverse proxy from subdomain.example.com which affects the internal ip 192.168.xxx.x . This works great.
For now I want to reach another server in my network, let it call 192.168.xxx.Y .
The Y should be available under subdomain.example.com/Y .
How do I have to configure NGINX?
This is my first try - which does not work:
server {
listen 80;
server_name subdomain.example.com;
location / {
proxy_pass http://192.168.xxx.x:80;
}
location /Y {
proxy_pass http://192.168.xxx.Y:377;
}
}
Any suggestions what I am doing wrong?

NGINX Reverse Proxy redirecting instead of proxying

i have a NGINX server running as a reverse proxy. Proxy works for windows hosts however i have a owncloud server and the proxy will instead re wright the url to the internal host name or IP address. ex(I type cloud.example.com and my url bar will change to 10.1.1.19 which is unresolvable over wan
i have checked DNS records and made sure NGINX can resolve host name. also tried just forwarding http traffic to cloud server to make sure using domain name was not the issue.
server {
listen 80;
listen [::]:80;
server_name example.com;
location / {
proxy_pass http://10.1.1.16:80/;
}
}
server {
listen 80;
listen [::]:80;
server_name cloud.example.com;
location / {
proxy_pass http://10.1.1.19:80/;
}
}
server {
listen 80;
listen [::]:80;
server_name remote.example.com;
location / {
proxy_pass http://10.1.1.17:80/;
}
}
i just need NGINX to run as a proxy for "cloud.example.com" instead of rewriting URL
I found a partial answer to this -- Why is my Nginx reverse proxy doing a 301 redirect instead of proxying?.
For me, it kept nginx from changing the hostname (i.e. from good-domain.com to 10.1.5.5:8080), but there doesn't appear to be a way to stop nginx from appending the port to the client's request URL.
So, in using the answer referenced above, I was able to go from http://10.1.5.5:8080 to http://good-domain:8080. It's still not where I want to be, but it definitely gets me closer.

Unable to redirect from 80 to 8080 with nginx

I am unable to redirect my website from domain_name:8080 to domain_name:80
This is the code in my /etc/nginx/sites-available/file.
server {
listen *:80;
root /var/www/;
server_name domain_name;
location / {
proxy_pass http://127.0.0.1:8080/;
}
}
What's interesting is, I am able to access it without :8080 on LAN. I am using com.bmuschko.tomcat plugin with Gradle. Am I missing something?

Configure proxy_pass for intermittent service

I'm using Nginx within a Doccker container to host my application
I'm trying to configure Nginx to proxy traffic to the /.well-known/ directory to another container that handles the letsencrypt process to setup & renew SSL certificates, but I don't need that container to be running all the time, only when attempting to renew the certificates.
My idea was to use proxy_pass for the directory specific traffic, through to the leysencrypt container, but as it's not always running, the Nginx process exits complaining that the upstream is not available.
Is there a way to configure Nginx not to check the status of the upstream for proxy_pass setting?
Here's the current config, if it's useful…
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name domain.com;
root /var/www/html/web;
location / {
return 301 https://$host$request_uri;
}
location ^~ /.well-known/ {
proxy_pass http://letsencrypt/.well-known/;
}
}
I guess I could use an in app forwarding of files, but this feels clunky. I'd rather configure it within Nginx.
location ^~ /.well-known/ {
resolver 127.0.0.1;
set $upstream letsencrypt;
proxy_pass http://$upstream/.well-known/; # use variables to make nginx startable
}

'ERR_TOO_MANY_REDIRECTS' error nginx docker

I am using nginx docker for deploying my app in aws server. I have to access my api using nginx proxy url which looks like https://domain.com/api/. This is a https request so i have to set proxy redirection to another port where api service running and the service is running under another docker container in same server instance. so my nginx conf file looks like below,
server {
listen 80;
server_name domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name domain.com;
# add Strict-Transport-Security to prevent man in the middle attacks
add_header Strict-Transport-Security "max-age=31536000";
location /api/ {
proxy_pass http://my-public-ip-address:3000;
}
}
So my problem is that while I am trying to access the api endpoint using above url its showing ERR_TOO_MANY_REDIRECTS. So any one know about this issue? And also i went through all the article with same issue mentioned but no luck.