HTTP and HTTPS as said before it works perfectly with Nginx. Now i'm trying to do a "proxy reverse name-based port" using proxy_pass and alias for domain. I'm trying to access webmin page through https://webmin.website.it and it apparently work. It show me login page but then when I logon it redirect me to https://webmin.website.it:12321/index.php and not to the right page https://webmin.website.it/index.php. Obviusly same thing for alias PHPMYADMIN. Any ideas?
this is my ../nginx/site-available/website1
Code:
###################### HTTP ######################
server {
listen 80;
server_name website.it;
access_log /var/log/nginx/access.log;
location / {
proxy_pass http://192.168.10.52;
include /etc/nginx/proxy_params;
}
}
###################### HTTPS ######################
server {
### server port and name ###
listen 443;
ssl on;
server_name website1.it;
### SSL log files ###
access_log logs/ssl-access.log;
error_log logs/ssl-error.log;
### SSL cert files ###
ssl_certificate ssl/kamzata.in.crt;
ssl_certificate_key ssl/kamzata.in.key;
### Add SSL specific settings here ###
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
keepalive_timeout 60;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
### Access to SSL ###
location / {
proxy_pass https://192.168.10.52;
### force timeouts if one of backend is died ##
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
### Set headers ####
proxy_set_header Accept-Encoding "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
### Most PHP, Python, Rails, Java App can use this header ###
#proxy_set_header X-Forwarded-Proto https;##
#This is better##
proxy_set_header X-Forwarded-Proto $scheme;
add_header Front-End-Https on;
### By default we don't want to redirect it ####
proxy_redirect off;
}
}
###################### WEBMIN ######################
server {
### server port and name ###
listen 443;
ssl on;
server_name webmin.website1.it;
### SSL log files ###
access_log logs/ssl-access.log;
error_log logs/ssl-error.log;
### SSL cert files ###
ssl_certificate ssl/kamzata.in.crt;
ssl_certificate_key ssl/kamzata.in.key;
### Add SSL specific settings here ###
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
keepalive_timeout 60;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
### Access to SSL ###
location / {
proxy_pass https://192.168.10.52:12321;
### force timeouts if one of backend is died ##
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
### Set headers ####
proxy_set_header Accept-Encoding "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
### Most PHP, Python, Rails, Java App can use this header ###
#proxy_set_header X-Forwarded-Proto https;##
#This is better##
proxy_set_header X-Forwarded-Proto $scheme;
add_header Front-End-Https on;
### By default we don't want to redirect it ####
proxy_redirect off;
}
}
###################### PHPMYADMIN ######################
server {
### server port and name ###
listen 443;
ssl on;
server_name phpmyadmin.website1.it;
### SSL log files ###
access_log logs/ssl-access.log;
error_log logs/ssl-error.log;
### SSL cert files ###
ssl_certificate ssl/kamzata.in.crt;
ssl_certificate_key ssl/kamzata.in.key;
### Add SSL specific settings here ###
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
keepalive_timeout 60;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
### Access to SSL ###
location / {
proxy_pass https://192.168.10.52:12322;
### force timeouts if one of backend is died ##
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
### Set headers ####
proxy_set_header Accept-Encoding "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
### Most PHP, Python, Rails, Java App can use this header ###
#proxy_set_header X-Forwarded-Proto https;##
#This is better##
proxy_set_header X-Forwarded-Proto $scheme;
add_header Front-End-Https on;
### By default we don't want to redirect it ####
proxy_redirect off;
}
}
As second thing... is there a better way with conditional function to write a better and sort code? Such as...
Code:
if (http://www.website.it)
proxy_pass 192.168.10.52:80;
if (https://www.website.it)
proxy_pass 192.168.10.52:443;
if (https://webmin.website.it)
proxy_pass 192.168.10.52:12321;
if (https://phpmyadmin.website.it)
proxy_pass 192.168.10.52:12322;
etc...
As third thing... is there a way to use url_rewrite to work with ftp service?
Bookmarks