I want to use nginx as a revers ssl proxy.
I have a reset service with multiple apis and I want to have a place holder in the location configuration and use it in the proxy_pass
location /myapp/(\s+)/(\s+) {
proxy_pass http://localhost:9000/$1/$2;
}
Any idea how do I do it ?
Related
I'm hosting VueJS at google cloud storage bucket, app works only when using domain name without subpath: www.domain.com when using URL like: www.domain.com/sub/path I'm getting 404 error as it seem that NGINX is looking for this path in the bucket instead of let VueJS router take over.
I tried to follow older thread but in my case would not help.
Any ideas how to fix this?
location = / {
proxy_pass https://gcs/mygoogle-cloud-bucket/main.html;
proxy_set_header Host storage.googleapis.com;
}
location / {
rewrite /(.*) /$1 break;
proxy_pass https://gcs/mygoogle-cloud-bucket/$1$is_args$args;
proxy_redirect off;
index main.html;
proxy_set_header Host storage.googleapis.com;
}
It seems like what you need to do is to create a Static Website using Cloud Storage and VueJS.
With this bieng the case, there are a few things that needs to be clarified:
Cloud Storage doesn't support HTTPs, so yo uneed to use a Load Balancer.
Make sure the objects in your bucket are public.
Build the Vue project With Relative Path.
It is also recomended to set the special pages, but this is not necessary.
Set up your load balancer and the SSL certificate as it is mentioned here.
Configure routing rules.
Make sure you have connected your custom domain to your load balancer
This should get you going with your site. If you would like to check a worknig example, you can take a look at this one.
Your code should look something like:
location / {
rewrite /$ $uri$index_name;
proxy_set_header Host storage.googleapis.com;
proxy_pass https://gs/$bucket_name$uri;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
I have front proxy as apache and back proxy as nginx. back proxy config is like below
location /my-app {
proxy_pass http://localhost:18080/my-app/;
fastcgi_intercept_errors off;
}
The problem is whenever the request sent to upstream from back proxy then double slash added
to upstream --> /my-app//myappPath
I have tried to add slash at the end of location like below to avoid double slash but back proxy not receive any request from my front proxy. so no requests to upstream application.
Please kindly help me how to avoid this double slash situation in my back proxy.
location /my-app/ {
proxy_pass http://localhost:18080/my-app/;
fastcgi_intercept_errors off;
}
You are using this directive:
proxy_pass http://localhost:18080/my-app/
Remove the "/" at the end to:
proxy_pass http://localhost:18080/my-app
That will take care of the issue.
I want to proxy multiple domains to my vuejs app.
I have a VueJS application, with the following route: https://app.pingr.io/status/{id}.
What I want to do is to allow users to redirect their domains to this route. So, imagine we have a https://status.some-domain.com host, which is redirected using CNAME to https://app.pingr.io/status/status.some-domain.com.
I really can't figure out the nginx configuration for this.
What I have right now:
server {
listen 80 default_server;
server_name _;
location / {
#resolver 127.0.0.1 [::1];
#resolver 8.8.8.8;
proxy_pass https://app.pingr.io/status/test/;
}
location /js/ {
proxy_pass https://app.pingr.io/js/;
proxy_ssl_server_name on;
proxy_set_header Accept-Encoding "";
}
location /css/ {
proxy_pass https://app.pingr.io/css/;
proxy_set_header Accept-Encoding "";
}
}
Before passing $host variable to proxy_pass at first I'm trying to just proxy to /status/test with working js/css/images.
I managed to get js/css work, however instead of getting the content of /status/test route, I get redirected to the home page. I displayed routes in router.beforeEach, so I can see that the first route I'm being redirected to is home route.
I was trying different configurations, like including proxy_set_header host and other stuff, which actually broke the whole thing even more.
So what is the right way to do this? Once again, users should be able to redirect their domains to my vuejs route and pass their domain to a part of this route. The domain should be rewritten, so that it looks like the page belongs to their server/domain.
I have done some resarch for this matter and there are some unaswered question regarding my issue, however I managed to solve half of what is needed (thanks to people on the site).
Scenerio:
I have Nginx as a reverse proxy in internal corporate network. I need to pass traffic to Internet behind corporate proxy.
Half of the solution:
To achive this, following works fine:
server {
listen 80;
server_name myhost.com;
location / {
proxy_set_header Host google.com;
proxy_pass http://corporateproxy:9999/;
}
}
However, above solution does not use SSL between corporate proxy and google.com. Do you have any idea how to add SSL to this?
I have tried adding protocol or port to header but it is not working this way.
I cannot modify anything on the corporate proxy. It should work like this: the URL being accessed is with https it will be redirected to https; http to http. Unfortunatelly header that contains only dns name is treated as http request.
Unfortunatelly the simplest solution does not work because nginx does not respect http_proxy settings on RedHat Machine:
server {
listen 80;
server_name myhost.com;
location / {
proxy_pass https://google.com/;
}
}
Any help will be highly appreciated.
I'm trying to proxy a certain rest endpoint on my linux api box to my windows box. Here's what I have right now.
My linux api box
...
location ~ ^/api/v0/roslyn(.*)$ {
resolver 8.8.8.8;
proxy_pass $scheme://my-windows-box.com/roslyn$1;
}
For example, I'd like to proxy the following url
http://my-linux-box.com/api/v0/roslyn?q=5
to
http://my-windows-box.com/roslyn?q=5
However, it seems to be missing the querystring, so the regex is failing?
I don't think you can match the args by regex, try this instead
location /api/v0/roslyn {
resolver 8.8.8.8;
proxy_pass $scheme://my-windows-box.com/roslyn$is_args$query_string;
}