.Net Core 3.1 deploy on Centos 7 - linux

I am trying to run my .net Core web api application on Centos 7 + Plesk server. My application will be running in the subdomain. I set up a subdomain from the Plesk panel and transferred my files. After, I followed the article below step by step, it is not a very explanatory or helpful article.
https://learn.microsoft.com/tr-tr/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1
First of all, this path does not exist /etc/nginx/sites-available/default. So with the help of other articles, I created the file api.mysite.com.conf in the etc/nginx/conf.d folder.
To configure Nginx as a reverse proxy to forward HTTP requests to your
ASP.NET Core app, modify /etc/nginx/sites-available/default. Open it
in a text editor, and replace the contents with the following snippet.
server {
listen 80;
server_name api.mysite.com *.mysite.com;
location / {
.... same as in docs.
}
}
Secondly, I created the service file by following the document. "/usr/bin/dotnet" This directory does not exist at this step, the document is not surprising again.
I solved this step by typing "/usr/share/dotnet/dotnet" instead of "/usr/bin/dotnet".
sudo nano /etc/systemd/system/kestrel-webapi.service
[Unit]
Description=Example .NET Web API App running on Centos 7
[Service]
WorkingDirectory=/var/www/vhosts/mysite.com/api.mysite.com
ExecStart=/usr/share/dotnet/dotnet /var/www/vhosts/mysite.com/api.mysite.com
After creating the service, I ran it without any problems.
The next step was Apache configuration.
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1
Configuration files for Apache are located within the
/etc/httpd/conf.d/ directory. Any file with the .conf extension is
processed in alphabetical order in addition to the module
configuration files in /etc/httpd/conf.modules.d/, which contains any
configuration files necessary to load modules.
I'm creating a configuration file in the "/etc/httpd/conf.d" file.
<VirtualHost *:*>
RequestHeader set "X-Forwarded-Proto" expr=${REQUEST_SCHEME}
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName www.mysite.com
ServerAlias *.mysite.com
ErrorLog ${APACHE_LOG_DIR}webapi-error.log
CustomLog ${APACHE_LOG_DIR}webapi-access.log common
</VirtualHost>
After making this configuration, I got an error while running the following commands in order.
sudo service httpd configtest
sudo systemctl restart httpd
[Fri May 28 19:35:02.344213 2021] [core:warn] [pid 25339:tid 139880432744576] AH00111: Config variable ${REQUEST_SCHEME} is not defined
[Fri May 28 19:35:02.344814 2021] [core:warn] [pid 25339:tid 139880432744576] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Fri May 28 19:35:02.344853 2021] [core:warn] [pid 25339:tid 139880432744576] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
Syntax OK
May 28 19:39:16 localhost.localdomain httpd[25740]: [Fri May 28 19:39:16.897163 2021] [core:warn] [pid 25740:tid 140630647605376] AH00111: Config variable ${REQUEST_SCHEME} is not defined
May 28 19:39:16 localhost.localdomain httpd[25740]: [Fri May 28 19:39:16.897775 2021] [core:warn] [pid 25740:tid 140630647605376] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
May 28 19:39:16 localhost.localdomain httpd[25740]: [Fri May 28 19:39:16.897825 2021] [core:warn] [pid 25740:tid 140630647605376] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
May 28 19:39:16 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
May 28 19:39:16 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
May 28 19:39:16 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
May 28 19:39:16 localhost.localdomain systemd[1]: httpd.service failed.
Before doing these operations, when I opened api.mysite.com through the browser, the plesk panel welcome page was displayed. I solved this problem by writing the following code, now I am getting 403 forbidden error.
mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf_backup
How do I solve the above two problems? How can I redirect to my web api application when I connect to api.mysite.com?
I've been struggling with this for 3 days and I can't find the right articles on the internet, is there anyone who can help me?

I solved the problem.
When we create a domain in the plesk panel, apache creates its own configuration file, so all I have to do is change the Additional apache directives settings from within Apache & nginx under the Hosting & DNS settings of the relevant domain from the plesk panel.
Plesk --> Websites & Domains --> <> --> Hosting & DNS --> Apache & nginx
Additional directives for HTTP
Header set Access-Control-Allow-Origin "http://yourdomain.com"
Header set Access-Control-Allow-Headers "Access-Control-Allow-Headers, Origin, Accept,
X-Requested-With, Content-Type, Access-Control-Request-Method, Access-ControlRequest-Headers, Authorization, Content-Disposition"
Header set Access-Control-Allow-Methods "*"
Header set Access-Control-Allow-Credentials "true"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
Additional directives for HTTPS
Header set Access-Control-Allow-Origin "https://yourdomain.com"
Header set Access-Control-Allow-Headers "Access-Control-Allow-Headers, Origin, Accept,
X-Requested-With, Content-Type, Access-Control-Request-Method, Access-ControlRequest-Headers, Authorization, Content-Disposition"
Header set Access-Control-Allow-Methods "*"
Header set Access-Control-Allow-Credentials "true"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
If you have a cors problem, you can add lines starting with header set.
After doing all these, your application will run if it is ready in your service file.

Related

Migrate web application from xmapp to lamp

I have developed web application using codeigniter on xampp server.
and want to deploy it on LAMP server. I have migrated database and app successfully but facing some problem.
When request web page using browser its not show anything not even error.
I have enabled selinux,
have root account and testing using root account
virtual host file config in /etc/httpd/conf.modules.d/hotelking.conf
<VirtualHost *:80>
ServerName www.hotelking.com
ServerAlias hotelking.com
DocumentRoot /var/www/hotelking/app/
Customlog "logs/www.hotelking.com.log" combined
ErrorLog "log/www.hotelking.com.error_log"
<Directory /var/www/hotelking/app/>
Require all granted
</Directory>
And error log have following error
[Wed Jan 06 03:20:14.515526 2016] [:error] [pid 6912] [client 127.0.0.1:40964] PHP Fatal error: Class 'MY_controller' not found in /var/www/hotelking/app/application/controllers/master.php on line 5
[Wed Jan 06 03:20:21.773841 2016] [:error] [pid 6908] [client 127.0.0.1:40965] PHP Fatal error: Class 'MY_controller' not found in /var/www/hotelking/app/application/controllers/master.php on line 5
I CHECKED IT HAS MY_controller at give location

Linux/Debian Apache2 mod_rewrite internal error

i have some problems to setup my mod_rewrite for my Joomla-Site.
Im using Apache 2.2.22 on Debian.
Website is on Directory: /home/web/beta/
What i did:
1) Commands:
sudo a2enmod rewrite
sudo mkdir -p /var/run/apache2
sudo chown -R www-data /var/run/apache2
sudo a2enmod actions
sudo /etc/init.d/apache2 force-reload
2) Then i setup following file: /etc/apache2/sites-enabled/000-default
<Directory /home/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
3) The htaccess file at path /home/web/beta/.htaccess i set:
RewriteEngine On
(I took the .htaccess from this site: http://www.joomla-security.de/downloads.html)
Ok, now the Problem.
As long as i set the AllowOverride to FileInfo i get following error message:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, webmaster#localhost and
inform them of the time the error occurred, and anything you might
have done that may have caused the error.
More information about this error may be available in the server error
log. Apache/2.2.22 (Debian) Server at XXXXXXX.com Port 80
What i did wrong?
Can you help me please?
EDIT: Error Log:
[Wed Nov 11 19:21:56 2015] [notice] caught SIGTERM, shutting down
[Wed Nov 11 19:21:57 2015] [notice] Apache/2.2.22 (Debian) PHP/5.4.45-0+deb7u2 configured -- resuming normal operations
[Wed Nov 11 19:21:57 2015] [alert] [client XX.XX.XX.198] /home/web/beta/.htaccess: Options not allowed here
[Wed Nov 11 19:21:58 2015] [alert] [client XX.XX.XX.198] /home/web/beta/.htaccess: Options not allowed here
[Wed Nov 11 19:21:59 2015] [alert] [client XX.XX.XX.144] /home/web/beta/.htaccess: Options not allowed here
It seems, from the errors you've posted, that you are trying to use the Options directive in .htaccess. To do that, you need to add Options to the AllowOverride directive in 000-default (cf. https://httpd.apache.org/docs/2.2/mod/core.html#options).
So change:
AllowOverride FileInfo
to
AllowOverride FileInfo Options
in 000-default.
Edit:
And if the above doesn't work, try changing it to:
AllowOverride All
And if that doesn't work then it could mean that other configuration files are getting loaded after 000-default and overwrite some of the directives.

Apache mod_wl2.4 plugin error parseJVMID

I have some issues with setting an clustered environment for weblogic and Apache. The structure is like this: 1 webserver that proxies requests to a clustered environment of 3 weblogic servers.
Everytime i send the request to the apache server , the request gets unhandled. I figured out a part of the problem , but that is something that is not intended in production. whenever i add DynamicServerList On the requests fail. When i switch it to off it works, but that means whenever a server fails , apache will still send requests to that server and user experience would be 0.
EDIT 1: I am using weblogic 12c and apache2.4 for Centos 7
EDIT 2: There is no firewall nor selinux active
Here is my config file for weblogic plugin:
<VirtualHost *:8080>
ServerAdmin postmaster#webserver2
ServerName webserver2
DocumentRoot /var/www/webserver2/htdocs
ErrorLog /var/log/httpd//webserver-error_log
CustomLog /var/log/httpd/webserver-access_log forwarded
<Directory />
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.html
<Location />
SetHandler weblogic-handler
</Location>
<IfModule mod_weblogic.c>
WeblogicCluster 192.168.166.70:8001,192.168.166.71:8001,192.168.166.69:8001
ConnectTimeoutSecs 15
ConnectRetrySecs 10
WLIOTimeoutSecs 600
DynamicServerList ON
Idempotent ON
FileCaching ON
KeepAliveSecs 60
KeepAliveEnabled ON
DebugConfigInfo ON
</IfModule>
</VirtualHost>
And the errors I get are the following:
[Mon Sep 14 09:54:58.480616 2015] [weblogic:error] [pid 15343:tid
140547949991680] [client 172.18.132.50:57991] <1534314422136982>
parseJVMID: could not resolve hostname '-1062689209'. Returning NULL
from parseJVMID
[Mon Sep 14 09:54:58.480681 2015] [weblogic:error]
[pid 15343:tid 140547949991680] [client 172.18.132.50:57991]
<1534314422136982> initJVMID: parseClusterServerList failure
[Mon Sep
14 09:55:28.481215 2015] [weblogic:error] [pid 15343:tid
140547949991680] [client 172.18.132.50:57991] <1534314422136982>
request [/clusterjsp/HaJsp.jsp] did NOT process
successfully..................

Configure Apache web server to perform SSL authentication

I'm trying to perform SSL authentication in apache web server, using XAMPP in Linux. After I configure httpd.conf like this, Apache server is failing to start. Can some one help me to fix this ? What is wrong with my configuration ?
Alias /bitnami/ "/opt/lampp/apache2/htdocs/"
Alias /bitnami "/opt/lampp/apache2/htdocs"
<Directory "/opt/lampp/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Listen 443
<VirtualHost 127.0.0.1:443>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost.localdomain
SSLEngine on
SSLCertificateFile "/home/lahiru/Desktop/ucsc/security/ssl/server.cer"
SSLCertificateKeyFile "/home/lahiru/Desktop/ucsc/security/ssl/server.key"
SSLVerifyClient require
SSLVerifyDepth 10
SSLCACertificateFile "/home/lahiru/Desktop/ucsc/security/ssl/ca.cer"
</VirtualHost>
And the Apache error log says,
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:443
[Sun Jun 21 07:42:47.000754 2015] [ssl:warn] [pid 1863] AH01909: localhost.localdomain:443:0 server certificate does NOT include an ID which matches the server name
[Sun Jun 21 07:42:47.001082 2015] [ssl:warn] [pid 1863] AH01906: www.example.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sun Jun 21 07:42:47.001101 2015] [ssl:warn] [pid 1863] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Jun 21 07:42:47.001183 2015] [suexec:notice] [pid 1863] AH01232: suEXEC mechanism enabled (wrapper: /opt/lampp/bin/suexec)
Bitnami developer here,
In XAMPP the SSL configuration is located at /opt/lampp/etc/extras/httpd-ssl.conf file, where there is a default VirtualHost already configured in port 443, and you are trying to bind again the same port.
Please, try to modify this file instead. You can check if there is any other process using port 443 running command sudo netstat -vnpa | grep 443
What do you mean with "Apache server is failing to start"? Using the /opt/lampp/ctlscript.sh script to restart Apache server didn't produce any error message on my side but the error_log told me the same that you mentioned.
Regards,
Gonzalo

mod_jk status page not working

I am doing clustering in Tomcat 7 with Apache server. It is working fine too. However I have the following issues:
1) I am trying to monitor the mod_jk status page; but it is giving 404 error.
2) in Log following error is shown -
[Tue Dec 17 13:16:51.019 2013] [2236:140599476504544] [error] init_jk::mod_jk.c (3348): Initializing shm:/etc/httpd/logs/mod_jk.shm.2236 errno=13. Load balancing workers will not function properly.
[Tue Dec 17 13:16:51.019 2013] [2236:140599476504544] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
[Tue Dec 17 13:16:51.041 2013] [2237:140599476504544] [error] init_jk::mod_jk.c (3348): Initializing shm:/etc/httpd/logs/mod_jk.shm.2237 errno=13. Load balancing workers will not function properly.
[Tue Dec 17 13:16:51.042 2013] [2237:140599476504544] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
Here is worker.properties file
worker.list=tomcatnode1,tomcatnode2,loadbalancer,statusmanager
worker.tomcatnode1.port=8009
worker.tomcatnode1.host=localhost
worker.tomcatnode1.type=ajp13
worker.tomcatnode1.lbfactor=100
worker.tomcatnode2.port=8010
worker.tomcatnode2.host=localhost
worker.tomcatnode2.type=ajp13
worker.tomcatnode2.lbfactor=100
#Load Balance Configuration
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=tomcatnode1, tomcatnode2
worker.loadbalancer.sticky_session=1
#worker.list=jkstatus
worker.statusmanager.type=status
Here is mod_jk.conf file
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkShmFile logs/mod_jk.shm
JkMount /IntellixWebApi/* loadbalancer
#JkMount /jkmanager/* jkstatus
#JkMount /jkmanager jkstatus
<Location /status/>
JkMount statusmanager
Order deny,allow
# Deny from all
Allow from 127.0.0.1
</Location>
If I am accessing IntellixWebApi; it is accessable. but When I am using /status; it is not working.
Please suggest.
Thanks
After lots of googling; I am able to get the jk_manager status screen. Firstly I have disable the SELINUX and then after restarting the system; I set the following JkMount
JkMount /* loadbalancer
JkMount /IntellixWebApi/* loadbalancer
JkMount /jkmanager/* jkstatus
<Location /status/>
JkMount statusmanager
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
This worked for me.
Thanks

Resources