I have nginx frontend and tomcat backend. Now I need to encryt the specific url end with .do
from client to nginx server using ssl. And js/css could be requsted with http. In order to avoid mixed content with http resource when request https, I also set .jsp
without https.
This's my main nginx.conf
:
server {
listen 80;
server_name localhost;
...
location / {
root /apps/oa/oaapp/OA1;
index index.jsp index.html;
}
location ~ .*\.do$ {
rewrite ^(.*)$ https://ittest.example.com$1 permanent;
}
}
server {
listen 443;
server_name ittest.example.com;
ssl on;
...
location / {
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_pass http://localhost:8080/;
}
But the problem occurs when I login via http://ittest.example.com/login.html
. The page send username and password to http://ittest.example.com/member/login.do
to handle the request. My rewrite rule redirect it to https:/ittest.example.com/member/login.do
(ssl encrytion).
But I see the request method is changed from POST to GET and with Chrome Development Tool I see no username/password send to server. So fail!
What shoud I do to make it right?
The page send username and password to http://ittest.example.com/member/login.do
If your form submits to http - there is absolutely no point redirecting to https, the password has already been transfered in plain text - submit to the right place.