Attempting to redirect is not working as expected - nginx-reverse-proxy

When I go to https://www.something.org:8443
It redirects from my Nginx proxy server to my Proxmox server using the following location settings:
ProxMox Nginx Settings Site
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass https://10.10.0.10:8006/;
proxy_buffering off;
client_max_body_size 0;
proxy_connect_timeout 3600s;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
sent_timeout 3600s;
}
The problem is I use my reverse proxy for other paths for other services, so I want it to work when I use the following URL:
https://www.something.org:8443/pve01
But I can't seem to make the location work. I've done three different proxy_pass versions, as shown below.
I get a blank page on all three attempts, but all the scripts and CSS are 404
location /pve01/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
1.
proxy_pass https://10.10.0.10:8006/;
2.
proxy_pass https://10.10.0.10:8006/$request_uri;
3.
proxy_pass https://10.10.0.10:8006/;
rewrite ^/pve01(.*)$ $1 break;
proxy_buffering off;
client_max_body_size 0;
proxy_connect_timeout 3600s;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
sent_timeout 3600s;
}
Any ideas/tips that can help this problem? Thanks

I believe the issue lies with the trailing slash, which doesn't pass on the rest of the URL, removing it should do the trick:
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass https://10.10.0.10:8006;
proxy_buffering off;
client_max_body_size 0;
proxy_connect_timeout 3600s;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
sent_timeout 3600s;
}
Edit:
And if you want only a specific location to be redirected, you could do something like:
location /pve01 {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass https://10.10.0.10:8006;
proxy_buffering off;
client_max_body_size 0;
proxy_connect_timeout 3600s;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
sent_timeout 3600s;
}
Removing the trailing slash from both the location and the proxy_pass statement should match any URL starting with the location specified, and should pass the entire URL to the specified proxy_pass IP.

Related

Nginx proxy for vue and fastapi

I am trying to deploy my app with vue.js as frontend and fastapi as backend. But I am having issue when deploy the app on the cloud. I have nginx configure like below.
I am binding backend to port 8080 and frontend to 8000. But with this configuration, I can only see my frontend page. The backend api is not respond. Can anyone show me how to fix it?
server {
listen 80;
server_name example.com;
charset utf-8;
root vis/dist;
index index.html index.htm;
location /api/ {
proxy_pass http://127.0.0.1:8000;
}
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_redirect off;
proxy_connect_timeout 90s;
proxy_read_timeout 90s;
proxy_send_timeout 90s;
}
error_log /var/log/nginx/vue-app-error.log;
access_log /var/log/nginx/vue-app-access.log;
}

Nginx config for vue app and express server

I have a ubuntu server on which I have a vue app and am trying to add an express app. Everything is working correctly in my vue app but the only route that works for my express location is the index route at /api.
here is my nginx.conf:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/vue/family-showdown/client/dist;
index index.html index.htm index.nginx-debian.html;
server_name _;
error_page 404 /;
location /api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_pass http://localhost:8080/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location / {
root /var/www/html/vue/family-showdown/client/dist;
}
}
in my express app.js I have:
app.use('/', _index["default"]);
app.use('/users', _users["default"]);
Navigating to /api works correctly so I would expect that navigating to /api/users should work but instead I get a 404 that says Cannot GET //users
there is no any location in your nginx configuration for /users path. you can try this configuration.
location / {
root /var/www/html/vue/family-showdown/client/dist;
index index.html;
include /etc/nginx/mime.types;
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /users/ {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
and delete these configurations
root /var/www/html/vue/family-showdown/client/dist;
index index.html index.htm index.nginx-debian.html;
server_name _;
error_page 404 /;
location / {
root /var/www/html/vue/family-showdown/client/dist;
}

Point subdomain to node express custom route with Nginx Proxy

I have a domain configured with nginx proxy to route like this:
mydomain.com -> localhost:3000
But now, I want a particular subdomain, to point to something like this:
subdomain.mydomain.com -> localhost:3000/mypage
Tried several things but I can't make it work:
server {
listen 80;
server_name subdomain.mydomain.com;
server_tokens off;
proxy_hide_header X-Powered-By;
location /healthcheck {
access_log off;
proxy_pass http://localhost:3000;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}
# NGINX will reject anything not matching /
location ~ /(?<section>.+)/ {
# Reject requests with unsupported HTTP method
if ($request_method !~ ^(GET|POST|HEAD|OPTIONS|PUT|DELETE)$) {
return 405;
}
# Only requests matching the whitelist expectations will
# get sent to the application server
proxy_pass http://localhost:3000/mypage/$section;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}
}

How to set nginx reverse proxy Apache-2.4(php5_module) with mod_remoteip

internet -> nginx -> apache-2.4
Remote_Addr prints 127.1.1.0 instead of client ip. I have apache behaind nginx with the following settings:
nginx.conf:
location / {
try_files $uri #apache;
}
location #apache {
internal;
proxy_pass http://127.0.0.1:8080;
include proxy.conf;
}
location ~ .*\.(php|php5)?$ {
proxy_pass http://127.0.0.1:8080;
include proxy.conf;
}
proxy.conf:
proxy_connect_timeout 300s;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 32k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_set_header Referer $http_referer;
proxy_set_header Cookie $http_cookie;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
httpd.conf:
Listen 127.0.0.1:8080
Include conf/extra/httpd-remoteip.conf
httpd-remoteip.conf:
LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1
sed -i "s#LogFormat \"%h %l#LogFormat \"%h %a %l#" /usr/local/apache/conf/httpd.conf

How to make youtrack not show solved issues

I am trying to figure out how to make Youtrack not show the resolved issues. It doesn't make sense. Is there an option to disable this by default?
I think the answer is that if you don't want to show resolved issues, you have to manually incorporate this in your search terms (include #unresolved or whatever works for your situation). You can of course save searches, and bookmark searches. But I haven't found a way to, by default, include #unresolved in all searches.
Our team is new to YouTrack, but in the current cloud version I found a way to do this. I'm assuming you are referring to the /issues page.
Create a saved search for unresolved issues - "Unresolved"
Update the dropdown to the right of the search bar from "Everything" to your saved search "Unresolved"
Reload the page and it defaults to "Unresolved." Whoo hoo!
You can use a trick which needs nginx or something to proxy YouTrack.
Add -Djetbrains.youtrack.baseUrl=http://127.0.0.1:PORT1 to the wrapper.conf file.
Then make nginx automatically change /issues queries for you.
server {
listen PORT2;
server_name IP_FQDN;
error_log /var/log/nginx/error.log debug;
location / {
proxy_pass http://localhost:PORT1;
client_max_body_size 10m;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
}
location /issues {
if ($args ~* (.*)(q=)(.*)) {
set $first_part $1;
set $last_part $3;
}
if ($last_part !~ "(.*)(Unresolved)(.*)") {
set $args "${first_part}q=%23Unresolved%20${last_part}";
}
if ($args = ""){
rewrite ^/issues /issues?q=%23Unresolved break;
}
proxy_pass http://localhost:PORT1;
client_max_body_size 10m;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
}
location /api/eventSourceBus {
proxy_cache off;
proxy_buffering off;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
proxy_set_header Connection '';
chunked_transfer_encoding off;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_pass http://localhost:PORT1;
}
}
I just use "for: me -Resolved", that shows all the unresolved tickets that are assigned to my user profile