#upstream tomcatserver{
# server 127.0.0.1:8080 weight=10;
#}
server {
listen 80;
listen [::]:80;
#自动跳转到HTTPS(可选,和下面的部分域名跳转不能同时使用)
if ($server_port = 80){
rewrite ^(/.*)$ https://$host$1 permanent;
}
# SSL config
# ration
#
listen 443 ssl default_server http2;
listen [::]:443 ssl default_server http2;
ssl_certificate Nginx/1_superting.cn_bundle.crt;
ssl_certificate_key Nginx/2_superting.cn.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name superting.cn;
# location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
# #proxy_pass http://tomcatserver;
# }
# 全文重点
location /AssistedLearningSystem_war{
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/AssistedLearningSystem_war;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
location ~.php($|/) {
fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi.conf;
include fastcgi_params;
}
#location /AssistedLearningSystem/{
# proxy_pass http://tomcatserver
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
nginx 代理tomcat war包服务
最新推荐文章于 2023-04-12 11:14:06 发布