Home Backend Development PHP Tutorial Use nginx reverse proxy tomcat service

Use nginx reverse proxy tomcat service

Jul 29, 2016 am 08:55 AM
error html index log server

Use nginx reverse proxy tomcat service
This experiment requires nginx service and tomcat service {I won’t talk about how to install them specifically}

Environment:
1.centos6.5
2.iptables and selinux are closed
3. Start all services
Use nginx reverse proxy tomcat service

Idea: Specify the corresponding services in the nginx configuration file.

nginx.conf configuration content:

<code><span>#user  nobody;</span>
worker_processes  <span>2</span><span>;</span><span>#error_log  logs/error.log;</span><span>#error_log  logs/error.log  notice;</span><span>#error_log  logs/error.log  info;</span><span>#pid        logs/nginx.pid;</span>events {
    worker_connections  <span>1024</span><span>;</span>
}


http {
    include       mime<span>.types</span><span>;</span>
    default_type  application/octet-stream<span>;</span><span>#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '</span><span>#                  '$status $body_bytes_sent "$http_referer" '</span><span>#                  '"$http_user_agent" "$http_x_forwarded_for"';</span><span>#access_log  logs/access.log  main;</span>    sendfile        on<span>;</span><span>#tcp_nopush     on;</span><span>#keepalive_timeout  0;</span>
    keepalive_timeout  <span>65</span><span>;</span><span>#gzip  on;</span><span>#   server {</span><span>#       listen       80;</span><span>#       server_name  shinyv.cc.com;</span><span>#charset koi8-r;</span><span>#access_log  logs/host.access.log  main;</span><span>#       location / {</span><span>#           root   html;</span><span>#           index  index.html index.htm;</span><span>#       }</span><span>#error_page  404              /404.html;</span><span># redirect server error pages to the static page /50x.html</span><span>#</span><span>#       error_page   500 502 503 504  /50x.html;</span><span>#       location = /50x.html {</span><span>#           root   html;</span><span>#      }</span><span># proxy the PHP scripts to Apache listening on 127.0.0.1:80</span><span>#</span><span>#location ~ \.php$ {</span><span>#    proxy_pass   http://127.0.0.1;</span><span>#}</span><span># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000</span><span>#</span><span>#location ~ \.php$ {</span><span>#    root           html;</span><span>#    fastcgi_pass   127.0.0.1:9000;</span><span>#    fastcgi_index  index.php;</span><span>#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;</span><span>#    include        fastcgi_params;</span><span>#}</span><span># deny access to .htaccess files, if Apache's document root</span><span># concurs with nginx's one</span><span>#</span><span>#location ~ /\.ht {</span><span>#    deny  all;</span><span>#}</span><span>#   }</span>    upstream  tomcat_web {
        server  <span>192.168</span><span>.140</span><span>.19</span>:<span>8080</span><span>;</span>
        }   
    server {
            listen <span>80</span><span>;</span>
            server_name         cui<span>.youfang</span><span>.com</span><span>;</span>
            access_log      /var/log/nginx/cui<span>.youfang</span><span>.access</span><span>.log</span><span>;</span>
            error_log       /var/log/nginx/cui<span>.youfang</span><span>.error</span><span>.log</span><span>;</span>            location / {
                proxy_set_header    Host $host<span>;</span>
                proxy_set_header    <span>Set</span>-Cookie $http_cookie<span>;</span>
                proxy_set_header    <span>X</span>-Real-Ip $remote_addr<span>;</span>
                proxy_set_header    <span>X</span>-Forwarded-For $remote_addr<span>;</span>
                proxy_pass    http://tomcat_web<span>;        </span>
            }
    }
    <span># another virtual host using mix of IP-, name-, and port-based configuration</span><span>#</span><span>#server {</span><span>#    listen       8000;</span><span>#    listen       somename:8080;</span><span>#    server_name  somename  alias  another.alias;</span><span>#    location / {</span><span>#        root   html;</span><span>#        index  index.html index.htm;</span><span>#    }</span><span>#}</span><span># HTTPS server</span><span>#</span><span>#server {</span><span>#    listen       443 ssl;</span><span>#    server_name  localhost;</span><span>#    ssl_certificate      cert.pem;</span><span>#    ssl_certificate_key  cert.key;</span><span>#    ssl_session_cache    shared:SSL:1m;</span><span>#    ssl_session_timeout  5m;</span><span>#    ssl_ciphers  HIGH:!aNULL:!MD5;</span><span>#    ssl_prefer_server_ciphers  on;</span><span>#    location / {</span><span>#        root   html;</span><span>#        index  index.html index.htm;</span><span>#    }</span><span>#}</span>}
</code>
Copy after login

After changing the configuration, nginx needs to be restarted
Because it is bound based on the domain name, you need to bind hosts:
Use nginx reverse proxy tomcat service

Then bind it in the hosts on the local PC:
Use nginx reverse proxy tomcat service

This is done; now you can test!

Test:

Whether it can be accessed by IP
Use nginx reverse proxy tomcat service

Open directly with domain name
Use nginx reverse proxy tomcat service

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the use of nginx reverse proxy tomcat service, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1667
14
PHP Tutorial
1273
29
C# Tutorial
1255
24
Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles