How to replicate session in memory on Oracle Weblogic? - session

I want to create a high availability with Oracle Weblogic. First, I create a cluster called MyCluster and add two servers (Server1 and Server2) to MyCluster. I use Nginx as a load balancer.
I follow the tutorial from https://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/12c/12-ManageSessions--4478/session.htm#t1 to replicate session in memory.
Here is my nginx config:
upstream myweb {
server server1:38080 weight=1;
server server2:38080 weight=1;
server server3:38080 weight=1;
}
server {
listen 80;
server_name nginxHost;
access_log /var/log/nginx/nginxHost.access.log main;
error_log /var/log/nginx/nginxHost.error.log warn;
location / {
proxy_pass http://myweb/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
When I test session replication, I have a problem. If Server1 is running and Server2 is shutdown now, I connect my application which is on Server1. I power on Server2 and wait it complete startup. Then I shutdown Server1 and refresh browser. The session disappear.
Finally, I find I have to refresh browser after Server2 is running. Is there any way to replicate session when servers start?

Related

Nginx Reverse Proxy For Web App Hosted on Local Server

I am hosting a web application via a home server. I have my Cloudflare DNS A record pointed to my public ip and my firewall is off. I am using cloud flare for SSL.
My app is running on local host (127.0.0.1) port 1624.
I am using nginx. My server name is my public ip and listen is port 80.
My reverse proxy is pointed at 127.0.0.1:1624.
I have port 80 open on my router as well.
For some reason I am not able to connect to my website. What could be causing this?
The developer of the web app has told me to use my domain name for the server name and keep the port as default 80 while pointing the reverse proxy to 127.0.0.1:1624.
My nginx conf:
server
{
server_name {mypublicip};
#server_name {mydomainname};
listen 80;
location / {
proxy_pass http://127.0.0.1:1624; # my web app proxy
proxy_http_version 1.1;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
#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;
}
}
}
Router Settings:
I've tried:
Nginx conf -
server_name > domain NAME
server_name > public ip
My app is working when I go to 127.0.0.1:1624 just not my domain.
You should configure port forwarding on your router - so that all packets coming on port 80 of the public IP on your router will be forwarded to port 80 of your local PC (which probably has an internal IP address in a 192.168.xx.yy range). Then your nginX should listen on port 80 at that 192.168.xx.yy address on your PC and proxy_pass to 127.0.0.1:1624 where your application is listening.
IF you don't do this - packets will end up on the router instead of at nginX in your local PC.

Where the response is comming from - Nginx? App? Kubernetes? Other?

I have an app providing RESTFull api in google kubernetes cluster.
In front of application i have an nginx working as a proxy_pass.
The problem is that one request of few thousands (1000, 2000) has bad data in response (other users data). Analysing logs showed that request of the bad response doesn't come to the application at all.
But it comes to nginx:
2019/05/08 13:48:03 [warn] 5#5: *28350 delaying request, excess: 0.664, by zone "one", client: 10.240.0.23, server: myportal.com, request: "GET /api/myresource?testId=10 HTTP/1.1"
In the same time there's no logs in the app for testId=10 (but there are for testId=9 and testId=11 when i make sequential test 1..1000)
Nginx configuration is almost default
limit_req_zone $binary_remote_addr zone=one:10m rate=4r/s;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name myportal.com;
if ($http_x_forwarded_proto = "http") {
return 308 https://$server_name;
}
charset utf-8;
access_log on;
server_tokens off;
location /api {
proxy_pass http://backend-service:8000;
limit_req zone=one burst=10;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
There is no caching configured (or maybe it's on by default?).
Application is working in google kubernetes environement, so the request chain looks like this
(k8s ingress, nginx-service) -> nginx -> (k8s backend-service) -> backend
Backend app is written in spring and using jetty to run.
Nginx version was updated from 1.13.X to 1.15.12 but both has the same issue.
I have no idea what and where should i check to find the cause of the problem.
Error you see comes from Nginx because of configs limit_req_zone $binary_remote_addr zone=one:10m rate=4r/s; and limit_req zone=one burst=10;
Read more here: http://nginx.org/ru/docs/http/ngx_http_limit_req_module.html
Did you put it for reason?

Kibana 5 not working behind nginx

I have setup ELK using docker (https://github.com/deviantony/docker-elk).
Then I added a subdomain to nginx with this config:
location / {
auth_basic "closed site";
auth_basic_user_file /var/www/passwd;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
proxy_pass http://localhost:5601;
}
When I now visit this subdomain I see that Kibana loads but then fails.
This is what my browser console shows:
When I visit Kibana directly using the IP of my server and the port 5601 it runs flawlessly. This only happens when being proxy_passed through nginx.

Create multiple websocket server with one port number

I am using netty 4.0.20 I want to create different websocket servers on the same port using different urls
for example,
wss://localhost:1234/PathA
wss://localhost:1234/PathB
wss://localhost:1234/PathC
is that possible?
Yes, this is possible with using reverse proxying, which can be done with Nginx.
This will require one additional server in your setup.
First you have to setup each server to listen to a different port and then you need the front end server to listen to your desired public port (in your case, this is 1234).
So lets say you have the following servers
Nginx listening at 0.0.0.0:1234
Netty that serves /PathA and listens at 0.0.0.0:1235
Netty that serves /PathB and listens at 0.0.0.0:1236
Netty that serves /PathC and listens at 0.0.0.0:1237
Now what you have to do is write an Nginx configuration file that will upgrade the connection from HTTP to Websocket and then reverse proxy each path to its corresponding server. An example configuration file that could do the job for you is the following.
{
listen 1234;
server_name localhost;
location ~PathA/$ {
proxy_pass http://localhost:1235;
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "upgrade";
}
location ~PathB/$ {
proxy_pass http://localhost:1236;
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "upgrade";
}
location ~PathC/$ {
proxy_pass http://localhost:1237;
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "upgrade";
}
}

Nginx/Django Admin POST https only

I've got an Nginx/Gunicorn/Django server deployed on a Centos 6 machine with only the SSL port (443) visible to the outside world. So unless the server is called with the https://, you won't get any response. If you call it with an http://domain:443, you'll merely get a 400 Bad Request message. Port 443 is the only way to hit the server.
I'm using Nginx to serve my static files (CSS, etc.) and all other requests are handled by Gunicorn, which is running Django at http://localhost:8000. So, navigating to https://domain.com works just fine, as do links within the admin site, but when I submit a form in the Django admin, the https is lost on the redirect and I'm sent to http://domain.com/request_uri which fails to reach the server. The POST action does work properly even so and the database is updated.
My configuration file is listed below. The location location / section is where I feel like the solution should be found. But it doesn't seem like the proxy_set_header X-* directives have any effect. Am I missing a module or something? I'm running nginx/1.0.15.
Everything I can find on the internet points to the X-Forwarded-Protocol https like it should do something, but I get no change. I'm also unable to get the debugging working on the remote server, though my next step may have to be compiling locally with debugging enabled to get some more clues. The last resort is to expose port 80 and redirect everything...but that requires some paperwork.
[http://pastebin.com/Rcg3p6vQ](My nginx configure arguments)
server {
listen 443 ssl;
ssl on;
ssl_certificate /path/to/cert.crt;
ssl_certificate_key /path/to/key.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
server_name example.com;
root /home/gunicorn/project/app;
access_log /home/gunicorn/logs/access.log;
error_log /home/gunicorn/logs/error.log debug;
location /static/ {
autoindex on;
root /home/gunicorn;
}
location / {
proxy_pass http://localhost:8000/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Protocol https;
}
}
Haven't had time yet to understand exactly what these two lines do, but removing them solved my problems:
proxy_redirect off;
proxy_set_header Host $host;

Resources